Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
update: updated username check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Sai committed Feb 22, 2024
1 parent b788340 commit 58664e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 14 additions & 14 deletions server/src/modules/auth/base/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,17 +397,17 @@ export class AuthService {
);
}

if (userDto.username && !this.isUsernameAllowed(userDto.username)) {
throw new HttpException(
{
status: HttpStatus.UNPROCESSABLE_ENTITY,
errors: {
username: 'invalid',
},
},
HttpStatus.UNPROCESSABLE_ENTITY
);
}
// if (userDto.username && !this.isUsernameAllowed(userDto.username)) {
// throw new HttpException(
// {
// status: HttpStatus.UNPROCESSABLE_ENTITY,
// errors: {
// username: 'invalid',
// },
// },
// HttpStatus.UNPROCESSABLE_ENTITY
// );
// }

await this.sessionService.softDelete({
user: {
Expand All @@ -423,9 +423,9 @@ export class AuthService {
});
}

private isUsernameAllowed(username: string) {
return /^[A-Za-z0-9]+$/.test(username);
}
// private isUsernameAllowed(username: string) {
// return /^[A-Za-z0-9]+$/.test(username);
// }

async refreshToken(
data: Pick<JwtRefreshPayloadType, 'sessionId'>
Expand Down
2 changes: 2 additions & 0 deletions server/src/modules/auth/base/dto/auth-update.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import {
IsAlphanumeric,
IsArray,
IsIn,
IsNotEmpty,
Expand Down Expand Up @@ -43,6 +44,7 @@ export class AuthUpdateDto {
@Validate(IsNotExist, ['User'], {
message: 'usernameAlreadyExists',
})
@IsAlphanumeric()
username?: string | null;

@ApiProperty()
Expand Down

0 comments on commit 58664e0

Please sign in to comment.