Skip to content

Commit

Permalink
bug/TUP-698: Confirm MFA unapairing on the portal instead of through …
Browse files Browse the repository at this point in the history
…TUP-services. (#422)

* Confirm MFA unapairing on the portal instead of through TUP-services.

* remove unused import
  • Loading branch information
jarosenb authored Feb 9, 2024
1 parent 81d6635 commit 2cf4369
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions libs/tup-components/src/mfa/MfaUnpairingView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Navigate } from 'react-router-dom';
import { useMfa } from '@tacc/tup-hooks';
import { Navigate, useLocation } from 'react-router-dom';
import { useConfig, useMfa, useProfile } from '@tacc/tup-hooks';
import {
Button,
InlineMessage,
Expand All @@ -16,6 +16,9 @@ import TicketCreateModal from '../tickets/TicketCreateModal';
import styles from './Mfa.module.css';

const MfaUnpairingView: React.FC = () => {
const { search } = useLocation();
const { data: profileData } = useProfile();
const unpairCode = new URLSearchParams(search).get('code');
const [currentToken, setCurrentToken] = useState('');
const { data, isLoading } = useMfa();
const { mutate: unpairWithCode, isError, isSuccess } = useMfaDelete();
Expand All @@ -38,6 +41,28 @@ const MfaUnpairingView: React.FC = () => {
otpcode: currentToken,
});
};
const { baseUrl } = useConfig();

if (unpairCode && profileData?.username)
return (
<>
<SectionMessage type="warning">
You are about to remove multifactor authentication from your account.
</SectionMessage>
<p className={styles['mfa-form']}>
{' '}
You are seeing this page because of a request we have received to
remove your multifactor authentication credential.
</p>
<p>
<a
href={`${baseUrl}/mfa/unpair/${profileData.username}/${unpairCode}`}
>
Click here to confirm removal of your MFA credential.
</a>
</p>
</>
);

if (isLoading || !data) {
return <LoadingSpinner />;
Expand Down Expand Up @@ -85,7 +110,7 @@ const MfaUnpairingView: React.FC = () => {
</Button>
</form>

{!sendChallengeSuccess && (
{!sendChallengeSuccess && !unpairCode && (
<p className={styles['mfa-message']}>
Alternatively,{' '}
<Button type="link" onClick={() => unpairWithEmail(null)}>
Expand Down

0 comments on commit 2cf4369

Please sign in to comment.