diff --git a/srcs/requirements/nestjs/api_back/src/auth/42/authentication.service.ts b/srcs/requirements/nestjs/api_back/src/auth/42/authentication.service.ts index b338ce7b..3d4098ac 100644 --- a/srcs/requirements/nestjs/api_back/src/auth/42/authentication.service.ts +++ b/srcs/requirements/nestjs/api_back/src/auth/42/authentication.service.ts @@ -24,10 +24,12 @@ export class AuthenticationService { if (!check_name) return await this.userService.create(createUsersDto); let createUsersDtoWithUsername : CreateUsersDto = createUsersDto; + let i = 0; while (check_name === true) { - createUsersDtoWithUsername = { ...createUsersDto, username: createUsersDto.username + randomUUID() }; + createUsersDtoWithUsername = { ...createUsersDto, username: createUsersDto.username + '_' + i}; check_name = await this.userService.isUsernameExists(createUsersDtoWithUsername.username); + i++; } return this.userService.create(createUsersDtoWithUsername); }