fix: address PR review feedback for 2FA implementation

This commit is contained in:
Jakub Trávník 2026-01-03 11:34:14 +01:00
parent a4d0c7b0c9
commit d1202e877f
4 changed files with 10 additions and 5 deletions

View file

@ -108,9 +108,9 @@ export default function LoginPage() {
verify2fa.mutate({
body: {
pendingSessionId,
code: twoFactorCode.trim(),
code: twoFactorCode,
},
} as Parameters<typeof verify2fa.mutate>[0]);
});
};
// Show 2FA verification form

View file

@ -127,10 +127,14 @@ export default function Settings({ loaderData }: Route.ComponentProps) {
setEnable2faStep("verify");
} else {
toast.error("Failed to setup 2FA", { description: data.message });
setEnable2faDialogOpen(false);
resetEnable2faDialog();
}
},
onError: (error) => {
toast.error("Failed to setup 2FA", { description: error.message });
setEnable2faDialogOpen(false);
resetEnable2faDialog();
},
});

View file

@ -4,6 +4,7 @@ import { authService } from "../modules/auth/auth.service";
export class CleanupSessionsJob extends Job {
async run() {
authService.cleanupExpiredSessions();
authService.cleanupExpiredPending2faSessions();
return { done: true, timestamp: new Date() };
}

View file

@ -179,7 +179,7 @@ export type GetTwoFactorStatusDto = typeof twoFactorStatusResponseSchema.infer;
// Verify 2FA DTO
export const verify2faBodySchema = type({
pendingSessionId: "string>0",
code: "string==6",
code: /^\d{6}$/,
});
const verify2faResponseSchema = type({
@ -248,7 +248,7 @@ export type Setup2faDto = typeof setup2faResponseSchema.infer;
// 2FA Enable DTO (verify code and enable)
export const enable2faBodySchema = type({
password: "string>0",
code: "string==6",
code: /^\d{6}$/,
secret: "string>0",
});
@ -284,7 +284,7 @@ export type Enable2faDto = typeof enable2faResponseSchema.infer;
// 2FA Disable DTO (require password and TOTP code)
export const disable2faBodySchema = type({
password: "string>0",
code: "string==6",
code: /^\d{6}$/,
});
const disable2faResponseSchema = type({