Skip to content

Commit 15c71c1

Browse files
committed
Add MFA status indicator to service and developer token tables
Display 2FA status (Y/N/?) with hover tooltip across all token types, not just login sessions. Refactored MfaStatusIndicator to use text labels instead of icons for clearer status display.
1 parent 32fedba commit 15c71c1

2 files changed

Lines changed: 20 additions & 28 deletions

File tree

src/features/account/LogInSessions.tsx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,21 @@ import { Loader } from '../../common/components';
1919
import { useAppSelector } from '../../common/hooks';
2020
import { useLogout } from '../login/LogIn';
2121

22-
const MfaStatusIndicator: FC<{ mfa: 'USED' | 'NOT_USED' | 'UNKNOWN' }> = ({
23-
mfa,
24-
}) => {
25-
if (mfa === 'USED') {
26-
return (
27-
<Tooltip title="MFA used">
28-
<span>
29-
<FontAwesomeIcon icon={faCheck} style={{ color: 'green' }} />
30-
</span>
31-
</Tooltip>
32-
);
33-
} else if (mfa === 'NOT_USED') {
34-
return (
35-
<Tooltip title="Single factor">
36-
<span>
37-
<FontAwesomeIcon icon={faX} style={{ color: 'red' }} />
38-
</span>
39-
</Tooltip>
40-
);
41-
} else {
42-
return (
43-
<Tooltip title="MFA status unknown">
44-
<span>
45-
<FontAwesomeIcon icon={faX} style={{ color: 'grey' }} />
46-
</span>
47-
</Tooltip>
48-
);
49-
}
22+
export const MfaStatusIndicator: FC<{
23+
mfa: 'USED' | 'NOT_USED' | 'UNKNOWN';
24+
}> = ({ mfa }) => {
25+
const config = {
26+
USED: { label: 'Y', tooltip: 'MFA used', color: 'green' },
27+
NOT_USED: { label: 'N', tooltip: 'Single factor', color: 'red' },
28+
UNKNOWN: { label: '?', tooltip: 'MFA status unknown', color: 'grey' },
29+
}[mfa];
30+
return (
31+
<Tooltip title={config.tooltip}>
32+
<span style={{ color: config.color, fontWeight: 'bold' }}>
33+
{config.label}
34+
</span>
35+
</Tooltip>
36+
);
5037
};
5138

5239
/**

src/features/account/ManageTokens.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { Loader } from '../../common/components';
2626
import { LabelValueTable } from '../../common/components/LabelValueTable';
2727
import { useAppSelector } from '../../common/hooks';
2828
import { useLogout } from '../login/LogIn';
29+
import { MfaStatusIndicator } from './LogInSessions';
2930

3031
/**
3132
* Content for the Log In Sessions tab in the Account page
@@ -136,6 +137,7 @@ export const ManageTokens: FC<{
136137
<TableCell>Created</TableCell>
137138
<TableCell>Expires</TableCell>
138139
<TableCell>Name</TableCell>
140+
<TableCell>MFA</TableCell>
139141
<TableCell></TableCell>
140142
</TableRow>
141143
</TableHead>
@@ -149,6 +151,9 @@ export const ManageTokens: FC<{
149151
{new Date(token.expires ?? 0).toLocaleString()}
150152
</TableCell>
151153
<TableCell>{token.name}</TableCell>
154+
<TableCell>
155+
{token.mfa && <MfaStatusIndicator mfa={token.mfa} />}
156+
</TableCell>
152157
<TableCell>
153158
<RevokeButton tokenId={token.id} />
154159
</TableCell>

0 commit comments

Comments
 (0)