fix(2FA): put disable 2FA cleanup in transaction

This commit is contained in:
Rudy B. committed 2026-04-25 18:39:08 +02:00
1 parent ebcc61c2b6
commit b4bb9cc727
2 files changed
+11 -5

No files matched your search

+5 -3
View File
@@ -101,9 +101,11 @@ export async function POST(request: Request) {
});
}
await markOtpUsed(userId, token);
await prisma.client.twoFactorAuth.delete({ where: { userId } });
await prisma.client.twoFactorBackupCode.deleteMany({ where: { userId } });
await prisma.transaction(async tx => {
await markOtpUsed(userId, token, tx);
await tx.twoFactorAuth.delete({ where: { userId } });
await tx.twoFactorBackupCode.deleteMany({ where: { userId } });
});
await resetRateLimit(userId);
return json({ ok: true });