fix(2FA): error when trying to setup an already activated 2FA
This commit is contained in:
1 parent
3e165a8c6f
commit
4b15f2ad7c
4 files changed
+12
No files matched your search
@@ -23,6 +23,15 @@ export async function POST(request: Request) {
|
||||
return badRequest({ message: 'User not found' });
|
||||
}
|
||||
|
||||
const existing = await prisma.client.twoFactorAuth.findUnique({ where: { userId } });
|
||||
|
||||
if (existing?.isEnabled) {
|
||||
return badRequest({
|
||||
code: 'two-factor-error-already-enabled',
|
||||
message: '2FA is already enabled',
|
||||
});
|
||||
}
|
||||
|
||||
const secret = generateTotpSecret();
|
||||
const encryptedSecret = encryptSecret(secret);
|
||||
const otpAuthUri = generateOtpAuthUri(secret, user.username);
|
||||
|
||||
Reference in new issue
Block a user