MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / MfaAlertContent

Function MfaAlertContent

console/src/components/MfaAlert.tsx:29–78  ·  view source on GitHub ↗
({ user }: { user: User })

Source from the content-addressed store, hash-verified

27export const MFA_DISMISSED_KEY = "mz-mfa-alert-dismissed";
28
29const MfaAlertContent = ({ user }: { user: User }) => {
30 const { data: mfaPolicy } = useMfaPolicy();
31
32 const [dismissedAt, setDismissedAt] = useLocalStorage<Date | null>(
33 MFA_DISMISSED_KEY,
34 null,
35 );
36
37 if (
38 // Only show this banner to org admins
39 !isSuperUser(user) ||
40 // Don't prompt them to enable MFA if they're using SSO
41 user.managedBy !== UserManagedByEnum.FRONTEGG ||
42 mfaPolicy === undefined ||
43 mfaPolicy.enforceMFAType === "Force" ||
44 mfaPolicy.enforceMFAType === "ForceExceptSAML" ||
45 (dismissedAt && new Date() < addDays(dismissedAt, 30))
46 ) {
47 return null;
48 }
49
50 return (
51 <AlertBanner variant="info" data-testid="mfa-required-alert" flexShrink="0">
52 <Flex justifyContent="center" width="100%">
53 <Text>
54 Please{" "}
55 <TextLink
56 href={`${location.href}#/admin-box/security/mfa`}
57 onClick={(e) => {
58 e.preventDefault();
59 location.hash = "/admin-box/security/mfa";
60 AdminPortal.show();
61 }}
62 >
63 require MFA
64 </TextLink>{" "}
65 for your organization.
66 </Text>
67 </Flex>
68 <CloseButton
69 position="relative"
70 right="0"
71 size="sm"
72 onClick={() => {
73 setDismissedAt(new Date());
74 }}
75 />
76 </AlertBanner>
77 );
78};
79
80export const MfaAlert = () => (
81 <AppConfigSwitch

Callers

nothing calls this directly

Calls 3

useMfaPolicyFunction · 0.90
isSuperUserFunction · 0.90
useLocalStorageFunction · 0.85

Tested by

no test coverage detected