feat: add public endpoint to resend user verification email by email address
This commit is contained in:
@@ -620,6 +620,41 @@ export class AuthService {
|
||||
};
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// RESEND VERIFICATION EMAIL BY EMAIL (PUBLIC)
|
||||
// ==========================================
|
||||
async resendVerificationByEmail(email: string) {
|
||||
// Always return success to prevent email enumeration attacks
|
||||
const successResponse = {
|
||||
message: 'If an account with this email exists and is not yet verified, a verification email has been sent.',
|
||||
};
|
||||
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { email: email.toLowerCase() },
|
||||
include: {
|
||||
userProfile: true,
|
||||
agentProfile: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user || user.emailVerified) {
|
||||
return successResponse;
|
||||
}
|
||||
|
||||
const profile = user.role === UserRole.AGENT ? user.agentProfile : user.userProfile;
|
||||
|
||||
// Emit event for email service to send verification
|
||||
this.eventEmitter.emit('user.registered', {
|
||||
userId: user.id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
firstName: profile?.firstName,
|
||||
lastName: profile?.lastName,
|
||||
});
|
||||
|
||||
return successResponse;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// REFRESH TOKEN
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user