accounts-frontend/packages/app/components/profile/multiFactorAuth/MultiFactorAuth.tsx

58 lines
2.3 KiB
TypeScript
Raw Normal View History

2019-12-07 16:58:52 +05:30
import React from 'react';
import { Helmet } from 'react-helmet-async';
2017-09-09 19:52:19 +05:30
import { FormattedMessage as Message } from 'react-intl';
import styles from 'app/components/profile/profileForm.scss';
import { BackButton } from 'app/components/profile/ProfileForm';
import { FormModel } from 'app/components/ui/form';
2017-07-22 21:27:38 +05:30
2019-12-07 16:58:52 +05:30
import MfaEnable, { MfaStep } from './MfaEnable';
2017-09-09 19:52:19 +05:30
import MfaDisable from './MfaDisable';
2017-07-22 21:27:38 +05:30
2019-12-07 16:58:52 +05:30
class MultiFactorAuth extends React.Component<{
2020-05-24 04:38:24 +05:30
step: MfaStep;
isMfaEnabled: boolean;
onSubmit: (form: FormModel, sendData: () => Promise<void>) => Promise<void>;
onComplete: () => void;
onChangeStep: (nextStep: number) => void;
2017-08-23 02:01:41 +05:30
}> {
2020-05-24 04:38:24 +05:30
render() {
const { step, onSubmit, onComplete, onChangeStep, isMfaEnabled } = this.props;
return (
<div className={styles.contentWithBackButton}>
<BackButton />
<div className={styles.form}>
<div className={styles.formBody}>
<Message key="mfaTitle" defaultMessage="Twofactor authentication">
2020-05-24 04:38:24 +05:30
{(pageTitle) => (
<h3 className={styles.title}>
<Helmet title={pageTitle as string} />
{pageTitle}
</h3>
)}
</Message>
<div className={styles.formRow}>
<p className={styles.description}>
<Message
key="mfaDescription"
defaultMessage="Twofactor authentication is an extra layer of security designed to ensure you that you're the only person who can access your account, even if the password gets stolen."
/>
2020-05-24 04:38:24 +05:30
</p>
</div>
</div>
{isMfaEnabled && <MfaDisable onSubmit={onSubmit} onComplete={onComplete} />}
</div>
{isMfaEnabled || (
<MfaEnable step={step} onSubmit={onSubmit} onChangeStep={onChangeStep} onComplete={onComplete} />
)}
</div>
2020-05-24 04:38:24 +05:30
);
}
2017-07-22 21:27:38 +05:30
}
2017-09-09 19:52:19 +05:30
export default MultiFactorAuth;