feat: Enhance password reset feedback by throwing specific exceptions for non-existent users or social logins.

This commit is contained in:
pradeepkumar
2025-12-22 13:14:12 +05:30
parent f0078401ee
commit 82d342508b

View File

@@ -319,17 +319,14 @@ export class AuthService {
where: { email: dto.email.toLowerCase() }, where: { email: dto.email.toLowerCase() },
}); });
// Always return success to prevent email enumeration
if (!user) { if (!user) {
return { throw new NotFoundException('No account found with this email address');
message: 'If the email exists, a password reset link will be sent',
};
} }
if (!user.password) { if (!user.password) {
return { throw new BadRequestException(
message: 'If the email exists, a password reset link will be sent', 'This account uses social login (Google/Facebook). Please sign in with your social account.',
}; );
} }
// Generate reset token (short-lived JWT) // Generate reset token (short-lived JWT)
@@ -350,7 +347,7 @@ export class AuthService {
}); });
return { return {
message: 'If the email exists, a password reset link will be sent', message: 'Password reset link has been sent to your email',
}; };
} }