mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 09:47:46 +03:00
Фикс регистрации для адекватной работы регистрации преподавателей.
This commit is contained in:
@@ -61,7 +61,7 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
async signUp(signUp: SignUpDto): Promise<User> {
|
async signUp(signUp: SignUpDto): Promise<User> {
|
||||||
const group = signUp.group.replaceAll(" ", "");
|
const group = signUp.group.replaceAll(" ", "");
|
||||||
const username = signUp.username.replaceAll(" ", "");
|
const username = signUp.username.trim();
|
||||||
|
|
||||||
if (![UserRole.STUDENT, UserRole.TEACHER].includes(signUp.role))
|
if (![UserRole.STUDENT, UserRole.TEACHER].includes(signUp.role))
|
||||||
throw new NotAcceptableException("Передана неизвестная роль");
|
throw new NotAcceptableException("Передана неизвестная роль");
|
||||||
@@ -100,7 +100,7 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
async signIn(signIn: SignInDto): Promise<User> {
|
async signIn(signIn: SignInDto): Promise<User> {
|
||||||
const user = await this.usersService.findUnique({
|
const user = await this.usersService.findUnique({
|
||||||
username: signIn.username.replaceAll(" ", ""),
|
username: signIn.username,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
import { ChangeUsernameDto } from "./dto/change-username.dto";
|
import { ChangeUsernameDto } from "./dto/change-username.dto";
|
||||||
import { ChangeGroupDto } from "./dto/change-group.dto";
|
import { ChangeGroupDto } from "./dto/change-group.dto";
|
||||||
import { V1ClientUserDto } from "./dto/v1/v1-client-user.dto";
|
import { V1ClientUserDto } from "./dto/v1/v1-client-user.dto";
|
||||||
|
import { UserRole } from "./user-role.enum";
|
||||||
|
|
||||||
@ApiTags("v1/users")
|
@ApiTags("v1/users")
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@@ -67,6 +68,11 @@ export class V1UsersController {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const user = await this.authService.decodeUserToken(token);
|
const user = await this.authService.decodeUserToken(token);
|
||||||
|
|
||||||
|
reqDto.username =
|
||||||
|
user.role == UserRole.ADMIN
|
||||||
|
? reqDto.username
|
||||||
|
: reqDto.username.replace(/\s/g, "");
|
||||||
|
|
||||||
return await this.usersService.changeUsername(user, reqDto);
|
return await this.usersService.changeUsername(user, reqDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user