Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ export class AuthService {
ipAddress: ipAddress || 'unknown',
userAgent: deviceType,
};
// check if email exists (maybe user registered in the meanwhile from another device)
const existingUser = await this.usersService.findByEmail(registrationData.email);
if (existingUser) {
throw new HttpException(
{
message: AUTH_ERROR_MESSAGES.EMAIL_REGISTERED,
code: AUTH_ERROR_CODES.EMAIL_REGISTERED,
},
HttpStatus.BAD_REQUEST,
);
}
const userId = await this.createUserAndSessionAndToken(userData, newSession, refreshToken);
const accessToken = await this.jwtService.signAsync({ id: userId.toString() });

Expand Down
Loading