From 82d342508b5997f4b6a2d601dfc701869602b02a Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 22 Dec 2025 13:14:12 +0530 Subject: [PATCH] feat: Enhance password reset feedback by throwing specific exceptions for non-existent users or social logins. --- src/auth/auth.service.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index dbbf0de..299329c 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -319,17 +319,14 @@ export class AuthService { where: { email: dto.email.toLowerCase() }, }); - // Always return success to prevent email enumeration if (!user) { - return { - message: 'If the email exists, a password reset link will be sent', - }; + throw new NotFoundException('No account found with this email address'); } if (!user.password) { - return { - message: 'If the email exists, a password reset link will be sent', - }; + throw new BadRequestException( + 'This account uses social login (Google/Facebook). Please sign in with your social account.', + ); } // Generate reset token (short-lived JWT) @@ -350,7 +347,7 @@ export class AuthService { }); return { - message: 'If the email exists, a password reset link will be sent', + message: 'Password reset link has been sent to your email', }; }