fix(2FA): return 429 when too many failed attemps
This commit is contained in:
1 parent
fc8d34f2e1
commit
fc32e39ac0
2 files changed
+20
-10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user