fix: Prevent Timing Attacks by Removing await in Password Reset Flow (#21747)

* fix: correct password reset request handling logic

* fix: handle password reset request errors more gracefully

---------

Co-authored-by: Sebastian Brunow <90863358+Bratpfanne-4000@users.noreply.github.com>
This commit is contained in:
Sebastian BrunowandSebastian Brunow authored and GitHub committed 2025-06-09 22:44:24 +00:00
1 parent 7d08c6724b
commit e781a78eea
1 file changed
+1 -2
@@ -37,8 +37,7 @@ async function handler(req: NextRequest) {
select: { name: true, email: true, locale: true },
});
// Don't leak info about whether the user exists
if (!user) return NextResponse.json({ message: "password_reset_email_sent" }, { status: 201 });
await passwordResetRequest(user);
if (user) passwordResetRequest(user).catch(console.error);
return NextResponse.json({ message: "password_reset_email_sent" }, { status: 201 });
} catch (reason) {
console.error(reason);