From d002a37322ffc78052f91458838d079c76a039af Mon Sep 17 00:00:00 2001 From: Joonsoo Kim Date: Thu, 23 Nov 2023 19:28:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Conflict=20Exception=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Conflict 발생 시 아이디, 이메일 둘 중 어떤 것으로 발생해도 무조건 아이디로 메세지가 가는 오류 수정 --- BE/src/auth/users.repository.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BE/src/auth/users.repository.ts b/BE/src/auth/users.repository.ts index c5bf786..e77c642 100644 --- a/BE/src/auth/users.repository.ts +++ b/BE/src/auth/users.repository.ts @@ -13,6 +13,17 @@ export class UsersRepository { const salt = await bcrypt.genSalt(); const hashedPassword = await bcrypt.hash(password, salt); + + const userIdDuplicate = await User.findOne({ where: { userId: userId } }); + if (userIdDuplicate) { + throw new ConflictException("중복된 아이디입니다."); + } + + const emailDuplicate = await User.findOne({ where: { email: email } }); + if (emailDuplicate) { + throw new ConflictException("중복된 이메일입니다."); + } + const user = User.create({ userId, password: hashedPassword,