Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/api/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface TokenResponse {
type: string;
user: string;
cachefor: number;
mfa: 'USED' | 'NOT_USED' | 'UNKNOWN';
}

interface AuthParams {
Expand Down Expand Up @@ -158,6 +159,7 @@ interface AuthResults {
device: string;
ip: string;
name?: string;
mfa: 'USED' | 'NOT_USED' | 'UNKNOWN';
}[];
user: string;
revokeallurl: string;
Expand Down
36 changes: 36 additions & 0 deletions src/features/account/LogInSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ import { Loader } from '../../common/components';
import { useAppSelector } from '../../common/hooks';
import { useLogout } from '../login/LogIn';

const MfaStatusIndicator: FC<{ mfa: 'USED' | 'NOT_USED' | 'UNKNOWN' }> = ({
mfa,
}) => {
if (mfa === 'USED') {
return (
<Tooltip title="MFA used">
<FontAwesomeIcon icon={faCheck} style={{ color: 'green' }} />
</Tooltip>
);
} else if (mfa === 'NOT_USED') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it makes it less readable... else makes it clear it's exclusive to the blocks above, especially for multiple if-else-ifs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie I agree it is "textually" (in execution) superfluous but I think it is sub-textually substantial

return (
<Tooltip title="Single factor">
<FontAwesomeIcon icon={faCheck} style={{ color: 'red' }} />
</Tooltip>
);
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

return (
<Tooltip title="MFA status unknown">
<FontAwesomeIcon icon={faCheck} style={{ color: 'grey' }} />
</Tooltip>
);
}
};

/**
* Content for the Log In Sessions tab in the Account page
*/
Expand Down Expand Up @@ -68,6 +92,7 @@ export const LogInSessions: FC = () => {
<TableCell>Browser</TableCell>
<TableCell>Operating System</TableCell>
<TableCell>IP Address</TableCell>
<TableCell>MFA Status</TableCell>
<TableCell>Action</TableCell>
</TableRow>
</TableHead>
Expand All @@ -86,6 +111,11 @@ export const LogInSessions: FC = () => {
{currentToken?.os} {currentToken?.osver}
</TableCell>
<TableCell>{currentToken?.ip}</TableCell>
<TableCell>
{currentToken?.mfa && (
<MfaStatusIndicator mfa={currentToken.mfa} />
)}
</TableCell>
<TableCell>
<LogOutButton tokenId={currentToken?.id} />
</TableCell>
Expand All @@ -105,6 +135,7 @@ export const LogInSessions: FC = () => {
<TableCell>Browser</TableCell>
<TableCell>Operating System</TableCell>
<TableCell>IP Address</TableCell>
<TableCell>MFA Status</TableCell>
<TableCell>Action</TableCell>
</TableRow>
</TableHead>
Expand All @@ -124,6 +155,11 @@ export const LogInSessions: FC = () => {
{otherToken.os} {otherToken.osver}
</TableCell>
<TableCell>{otherToken.ip}</TableCell>
<TableCell>
{otherToken.mfa && (
<MfaStatusIndicator mfa={otherToken.mfa} />
)}
</TableCell>
<TableCell>
<LogOutButton tokenId={otherToken.id} />
</TableCell>
Expand Down
1 change: 1 addition & 0 deletions src/features/auth/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface TokenInfo {
type: string;
user: string;
cachefor: number;
mfa: 'USED' | 'NOT_USED' | 'UNKNOWN';
}

interface AuthState {
Expand Down
Loading