feat: disable 2fa with backup codes (#1314)

Allow disabling two-factor authentication (2FA) by using either their
authenticator app (TOTP) or a backup code.
This commit is contained in:
Ephraim Duncan
2024-08-29 01:00:57 +00:00
committed by GitHub
parent 81479b5b55
commit 9e714d607e
6 changed files with 122 additions and 58 deletions

View File

@ -65,7 +65,8 @@ export const twoFactorAuthenticationRouter = router({
return await disableTwoFactorAuthentication({
user,
token: input.token,
totpCode: input.totpCode,
backupCode: input.backupCode,
requestMetadata: extractNextApiRequestMetadata(ctx.req),
});
} catch (err) {

View File

@ -9,7 +9,8 @@ export type TEnableTwoFactorAuthenticationMutationSchema = z.infer<
>;
export const ZDisableTwoFactorAuthenticationMutationSchema = z.object({
token: z.string().trim().min(1),
totpCode: z.string().trim().optional(),
backupCode: z.string().trim().optional(),
});
export type TDisableTwoFactorAuthenticationMutationSchema = z.infer<