fix: handle duplicate emails

This commit is contained in:
Abdalhamid Alhamad
2024-12-05 11:42:56 +03:00
parent 26b2d153fd
commit f97bb08c5c

View File

@ -73,6 +73,12 @@ export class AuthService {
throw new BadRequestException('USERS.EMAIL_ALREADY_SET'); throw new BadRequestException('USERS.EMAIL_ALREADY_SET');
} }
const existingUser = await this.userService.findUser({ email });
if (existingUser) {
throw new BadRequestException('USERS.EMAIL_ALREADY_TAKEN');
}
return this.userService.setEmail(userId, email); return this.userService.setEmail(userId, email);
} }