fix: address PR review feedback for 2FA implementation
This commit is contained in:
parent
a4d0c7b0c9
commit
d1202e877f
4 changed files with 10 additions and 5 deletions
|
|
@ -108,9 +108,9 @@ export default function LoginPage() {
|
||||||
verify2fa.mutate({
|
verify2fa.mutate({
|
||||||
body: {
|
body: {
|
||||||
pendingSessionId,
|
pendingSessionId,
|
||||||
code: twoFactorCode.trim(),
|
code: twoFactorCode,
|
||||||
},
|
},
|
||||||
} as Parameters<typeof verify2fa.mutate>[0]);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Show 2FA verification form
|
// Show 2FA verification form
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,14 @@ export default function Settings({ loaderData }: Route.ComponentProps) {
|
||||||
setEnable2faStep("verify");
|
setEnable2faStep("verify");
|
||||||
} else {
|
} else {
|
||||||
toast.error("Failed to setup 2FA", { description: data.message });
|
toast.error("Failed to setup 2FA", { description: data.message });
|
||||||
|
setEnable2faDialogOpen(false);
|
||||||
|
resetEnable2faDialog();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast.error("Failed to setup 2FA", { description: error.message });
|
toast.error("Failed to setup 2FA", { description: error.message });
|
||||||
|
setEnable2faDialogOpen(false);
|
||||||
|
resetEnable2faDialog();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { authService } from "../modules/auth/auth.service";
|
||||||
export class CleanupSessionsJob extends Job {
|
export class CleanupSessionsJob extends Job {
|
||||||
async run() {
|
async run() {
|
||||||
authService.cleanupExpiredSessions();
|
authService.cleanupExpiredSessions();
|
||||||
|
authService.cleanupExpiredPending2faSessions();
|
||||||
|
|
||||||
return { done: true, timestamp: new Date() };
|
return { done: true, timestamp: new Date() };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ export type GetTwoFactorStatusDto = typeof twoFactorStatusResponseSchema.infer;
|
||||||
// Verify 2FA DTO
|
// Verify 2FA DTO
|
||||||
export const verify2faBodySchema = type({
|
export const verify2faBodySchema = type({
|
||||||
pendingSessionId: "string>0",
|
pendingSessionId: "string>0",
|
||||||
code: "string==6",
|
code: /^\d{6}$/,
|
||||||
});
|
});
|
||||||
|
|
||||||
const verify2faResponseSchema = type({
|
const verify2faResponseSchema = type({
|
||||||
|
|
@ -248,7 +248,7 @@ export type Setup2faDto = typeof setup2faResponseSchema.infer;
|
||||||
// 2FA Enable DTO (verify code and enable)
|
// 2FA Enable DTO (verify code and enable)
|
||||||
export const enable2faBodySchema = type({
|
export const enable2faBodySchema = type({
|
||||||
password: "string>0",
|
password: "string>0",
|
||||||
code: "string==6",
|
code: /^\d{6}$/,
|
||||||
secret: "string>0",
|
secret: "string>0",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -284,7 +284,7 @@ export type Enable2faDto = typeof enable2faResponseSchema.infer;
|
||||||
// 2FA Disable DTO (require password and TOTP code)
|
// 2FA Disable DTO (require password and TOTP code)
|
||||||
export const disable2faBodySchema = type({
|
export const disable2faBodySchema = type({
|
||||||
password: "string>0",
|
password: "string>0",
|
||||||
code: "string==6",
|
code: /^\d{6}$/,
|
||||||
});
|
});
|
||||||
|
|
||||||
const disable2faResponseSchema = type({
|
const disable2faResponseSchema = type({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue