fix(2FA): return 429 when too many failed attemps

This commit is contained in:
Rudy B. committed 2026-04-25 17:56:56 +02:00
1 parent fc8d34f2e1
commit fc32e39ac0
2 files changed
+20 -10

No files matched your search

+10 -5
View File
@@ -73,11 +73,16 @@ export async function POST(request: Request) {
// Verify rate limit
const rateCheck = await checkRateLimit(userId);
if (!rateCheck.allowed) {
return badRequest({
code: 'two-factor-error-too-many-attempts',
message: 'Too many failed attempts',
lockedUntil: rateCheck.lockedUntil,
});
return Response.json(
{
error: {
code: 'two-factor-error-too-many-attempts',
message: 'Too many failed attempts',
lockedUntil: rateCheck.lockedUntil,
},
},
{ status: 429 },
);
}
// Prevent OTP replay
+10 -5
View File
@@ -33,11 +33,16 @@ export async function POST(request: Request) {
// Verify rate limit
const rateCheck = await checkRateLimit(userId);
if (!rateCheck.allowed) {
return badRequest({
code: 'two-factor-error-too-many-attempts',
message: 'Too many failed attempts',
lockedUntil: rateCheck.lockedUntil,
});
return Response.json(
{
error: {
code: 'two-factor-error-too-many-attempts',
message: 'Too many failed attempts',
lockedUntil: rateCheck.lockedUntil,
},
},
{ status: 429 },
);
}
// Prevent OTP replay