Skip to content

Commit 661c3a6

Browse files
samejrericallam
authored andcommitted
Show a confirmation modal before you can disable MFA
1 parent 3c067b3 commit 661c3a6

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

  • apps/webapp/app/routes/account.security

apps/webapp/app/routes/account.security/route.tsx

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export default function Page() {
137137
const [isMfaEnabled, setIsMfaEnabled] = useState(false);
138138
const [showQrDialog, setShowQrDialog] = useState(false);
139139
const [showRecoveryDialog, setShowRecoveryDialog] = useState(false);
140+
const [showDisableDialog, setShowDisableDialog] = useState(false);
140141
const [totpCode, setTotpCode] = useState("");
141142

142143
// TODO: Replace with actual data from backend
@@ -168,8 +169,8 @@ export default function Page() {
168169
// Show QR code dialog to enable MFA
169170
setShowQrDialog(true);
170171
} else if (!checked && isMfaEnabled) {
171-
// TODO: Handle disabling MFA - might need backend call
172-
setIsMfaEnabled(false);
172+
// Show confirmation dialog before disabling MFA
173+
setShowDisableDialog(true);
173174
}
174175
};
175176

@@ -214,6 +215,18 @@ export default function Page() {
214215
URL.revokeObjectURL(url);
215216
};
216217

218+
const handleDisableMfa = (e: React.FormEvent) => {
219+
e.preventDefault();
220+
// TODO: Handle disabling MFA - backend call
221+
setShowDisableDialog(false);
222+
setIsMfaEnabled(false);
223+
};
224+
225+
const handleDisableCancel = () => {
226+
setShowDisableDialog(false);
227+
// Don't change the switch state when canceling
228+
};
229+
217230
return (
218231
<PageContainer>
219232
<NavBar>
@@ -371,6 +384,32 @@ export default function Page() {
371384
</Form>
372385
</DialogContent>
373386
</Dialog>
387+
388+
{/* Disable MFA Confirmation Dialog */}
389+
<Dialog open={showDisableDialog} onOpenChange={setShowDisableDialog}>
390+
<DialogContent>
391+
<DialogHeader>
392+
<DialogTitle>Disable multi-factor authentication</DialogTitle>
393+
</DialogHeader>
394+
<Form method="post" onSubmit={handleDisableMfa}>
395+
<input type="hidden" name="action" value="disable-mfa" />
396+
<div className="pb-4 pt-3">
397+
<Paragraph>
398+
Are you sure you want to disable multi-factor authentication?
399+
</Paragraph>
400+
</div>
401+
402+
<DialogFooter>
403+
<Button type="button" variant="secondary/medium" onClick={handleDisableCancel}>
404+
Close
405+
</Button>
406+
<Button type="submit" variant="primary/medium" autoFocus>
407+
Disable MFA
408+
</Button>
409+
</DialogFooter>
410+
</Form>
411+
</DialogContent>
412+
</Dialog>
374413
</MainHorizontallyCenteredContainer>
375414
</PageBody>
376415
</PageContainer>

0 commit comments

Comments
 (0)