MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / DisableTwoFactor

Function DisableTwoFactor

apps/start/src/modals/disable-two-factor.tsx:11–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import { useTRPC } from '@/integrations/trpc/react';
10
11export default function DisableTwoFactor() {
12 const trpc = useTRPC();
13 const queryClient = useQueryClient();
14 const [code, setCode] = useState('');
15
16 const mutation = useMutation(
17 trpc.auth.totpDisable.mutationOptions({
18 onSuccess: () => {
19 toast.success('Two-factor authentication disabled');
20 queryClient.invalidateQueries(trpc.auth.totpStatus.pathFilter());
21 popModal();
22 },
23 onError: (error) => {
24 toast.error(error.message);
25 setCode('');
26 },
27 })
28 );
29
30 return (
31 <ModalContent>
32 <ModalHeader
33 text="Enter a code from your authenticator app, or a recovery code, to confirm."
34 title="Disable two-factor authentication"
35 />
36 <Input
37 autoCapitalize="characters"
38 autoFocus
39 onChange={(e) => setCode(e.target.value)}
40 placeholder="123456 or ABCDE-FGHIJ"
41 value={code}
42 />
43 <DialogFooter>
44 <Button onClick={() => popModal()} variant="secondary">
45 Cancel
46 </Button>
47 <Button
48 disabled={!code.trim()}
49 loading={mutation.isPending}
50 onClick={() => mutation.mutate({ code })}
51 variant="destructive"
52 >
53 Disable
54 </Button>
55 </DialogFooter>
56 </ModalContent>
57 );
58}

Callers

nothing calls this directly

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected