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
|
// Verify rate limit
|
||||||
const rateCheck = await checkRateLimit(userId);
|
const rateCheck = await checkRateLimit(userId);
|
||||||
if (!rateCheck.allowed) {
|
if (!rateCheck.allowed) {
|
||||||
return badRequest({
|
return Response.json(
|
||||||
code: 'two-factor-error-too-many-attempts',
|
{
|
||||||
message: 'Too many failed attempts',
|
error: {
|
||||||
lockedUntil: rateCheck.lockedUntil,
|
code: 'two-factor-error-too-many-attempts',
|
||||||
});
|
message: 'Too many failed attempts',
|
||||||
|
lockedUntil: rateCheck.lockedUntil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 429 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent OTP replay
|
// Prevent OTP replay
|
||||||
|
|||||||
@@ -33,11 +33,16 @@ export async function POST(request: Request) {
|
|||||||
// Verify rate limit
|
// Verify rate limit
|
||||||
const rateCheck = await checkRateLimit(userId);
|
const rateCheck = await checkRateLimit(userId);
|
||||||
if (!rateCheck.allowed) {
|
if (!rateCheck.allowed) {
|
||||||
return badRequest({
|
return Response.json(
|
||||||
code: 'two-factor-error-too-many-attempts',
|
{
|
||||||
message: 'Too many failed attempts',
|
error: {
|
||||||
lockedUntil: rateCheck.lockedUntil,
|
code: 'two-factor-error-too-many-attempts',
|
||||||
});
|
message: 'Too many failed attempts',
|
||||||
|
lockedUntil: rateCheck.lockedUntil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 429 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent OTP replay
|
// Prevent OTP replay
|
||||||
|
|||||||
Reference in new issue
Block a user