2019-12-07 13:28:52 +02:00
import React from 'react' ;
2019-12-30 09:29:39 +02:00
import { Helmet } from 'react-helmet-async' ;
2017-09-09 17:22:19 +03:00
import { FormattedMessage as Message } from 'react-intl' ;
2019-12-07 21:02:00 +02:00
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 18:57:38 +03:00
2019-12-07 13:28:52 +02:00
import MfaEnable , { MfaStep } from './MfaEnable' ;
2017-09-09 17:22:19 +03:00
import MfaDisable from './MfaDisable' ;
2017-07-22 18:57:38 +03:00
2019-12-07 13:28:52 +02:00
class MultiFactorAuth extends React . Component < {
2020-05-24 02:08:24 +03:00
step : MfaStep ;
isMfaEnabled : boolean ;
onSubmit : ( form : FormModel , sendData : ( ) = > Promise < void > ) = > Promise < void > ;
onComplete : ( ) = > void ;
onChangeStep : ( nextStep : number ) = > void ;
2017-08-22 23:31:41 +03:00
} > {
2020-05-24 02:08:24 +03:00
render() {
const { step , onSubmit , onComplete , onChangeStep , isMfaEnabled } = this . props ;
return (
< div className = { styles . contentWithBackButton } >
< BackButton / >
< div className = { styles . form } >
< div className = { styles . formBody } >
2020-06-04 19:41:27 +03:00
< Message key = "mfaTitle" defaultMessage = "Two‑ factor authentication" >
2020-05-24 02:08:24 +03:00
{ ( pageTitle ) = > (
< h3 className = { styles . title } >
< Helmet title = { pageTitle as string } / >
{ pageTitle }
< / h3 >
) }
< / Message >
< div className = { styles . formRow } >
< p className = { styles . description } >
2020-06-04 19:41:27 +03:00
< Message
key = "mfaDescription"
defaultMessage = "Two‑ factor 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 02:08:24 +03:00
< / p >
< / div >
< / div >
{ isMfaEnabled && < MfaDisable onSubmit = { onSubmit } onComplete = { onComplete } / > }
< / div >
{ isMfaEnabled || (
< MfaEnable step = { step } onSubmit = { onSubmit } onChangeStep = { onChangeStep } onComplete = { onComplete } / >
) }
2019-11-27 11:03:32 +02:00
< / div >
2020-05-24 02:08:24 +03:00
) ;
}
2017-07-22 18:57:38 +03:00
}
2017-09-09 17:22:19 +03:00
export default MultiFactorAuth ;