From af01a5e5cd6c8831a5b2d804d9fdba7b9db06409 Mon Sep 17 00:00:00 2001 From: Jaehyeon Kim <65964601+Jaehyeon1020@users.noreply.github.com> Date: Fri, 10 May 2024 10:00:51 +0000 Subject: [PATCH] chore(be): signup-for-load-test --- .../apps/client/src/user/user.service.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/backend/apps/client/src/user/user.service.ts b/apps/backend/apps/client/src/user/user.service.ts index d477c10f96..a47d48b7a0 100644 --- a/apps/backend/apps/client/src/user/user.service.ts +++ b/apps/backend/apps/client/src/user/user.service.ts @@ -285,6 +285,31 @@ export class UserService { email: signUpDto.email + randomUUID() } + const duplicatedUser = await this.prisma.user.findUnique({ + where: { + username: newSignUpDto.username + } + }) + if (duplicatedUser) { + this.logger.debug('username duplicated') + throw new DuplicateFoundException('Username') + } + + if (!this.isValidUsername(signUpDto.username)) { + this.logger.debug('signUp - fail (invalid username)') + throw new UnprocessableDataException('Bad username') + } else if (!this.isValidPassword(signUpDto.password)) { + this.logger.debug('signUp - fail (invalid password)') + throw new UnprocessableDataException('Bad password') + } + try { + await this.deletePinFromCache( + emailAuthenticationPinCacheKey(newSignUpDto.email) + ) + } catch (e) { + // pass + } + const user: User = await this.createUser(newSignUpDto) const CreateUserProfileData: CreateUserProfileData = { userId: user.id,