2019-12-23 01:03:44 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { useStoreState } from 'easy-peasy';
|
|
|
|
import { ApplicationStore } from '@/state';
|
|
|
|
import SetupTwoFactorModal from '@/components/dashboard/forms/SetupTwoFactorModal';
|
2019-12-23 04:41:25 +00:00
|
|
|
import DisableTwoFactorModal from '@/components/dashboard/forms/DisableTwoFactorModal';
|
2020-07-03 23:37:26 +01:00
|
|
|
import tw from 'twin.macro';
|
|
|
|
import Button from '@/components/elements/Button';
|
2019-12-23 01:03:44 +00:00
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const user = useStoreState((state: ApplicationStore) => state.user.data!);
|
2019-12-23 04:41:25 +00:00
|
|
|
const [ visible, setVisible ] = useState(false);
|
2019-12-23 01:03:44 +00:00
|
|
|
|
|
|
|
return user.useTotp ?
|
|
|
|
<div>
|
2019-12-23 04:51:50 +00:00
|
|
|
{visible &&
|
|
|
|
<DisableTwoFactorModal
|
2020-07-05 02:30:50 +01:00
|
|
|
appear
|
2019-12-23 04:51:50 +00:00
|
|
|
visible={visible}
|
|
|
|
onDismissed={() => setVisible(false)}
|
|
|
|
/>
|
|
|
|
}
|
2020-07-03 23:37:26 +01:00
|
|
|
<p css={tw`text-sm`}>
|
2019-12-23 01:03:44 +00:00
|
|
|
Two-factor authentication is currently enabled on your account.
|
|
|
|
</p>
|
2020-07-03 23:37:26 +01:00
|
|
|
<div css={tw`mt-6`}>
|
|
|
|
<Button
|
|
|
|
color={'red'}
|
|
|
|
isSecondary
|
2019-12-23 04:41:25 +00:00
|
|
|
onClick={() => setVisible(true)}
|
|
|
|
>
|
2019-12-23 01:03:44 +00:00
|
|
|
Disable
|
2020-07-03 23:37:26 +01:00
|
|
|
</Button>
|
2019-12-23 01:03:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
:
|
|
|
|
<div>
|
2019-12-23 04:51:50 +00:00
|
|
|
{visible &&
|
|
|
|
<SetupTwoFactorModal
|
2020-07-03 23:37:26 +01:00
|
|
|
appear
|
2019-12-23 04:51:50 +00:00
|
|
|
visible={visible}
|
|
|
|
onDismissed={() => setVisible(false)}
|
|
|
|
/>
|
|
|
|
}
|
2020-07-03 23:37:26 +01:00
|
|
|
<p css={tw`text-sm`}>
|
2019-12-23 01:03:44 +00:00
|
|
|
You do not currently have two-factor authentication enabled on your account. Click
|
|
|
|
the button below to begin configuring it.
|
|
|
|
</p>
|
2020-07-03 23:37:26 +01:00
|
|
|
<div css={tw`mt-6`}>
|
|
|
|
<Button
|
|
|
|
color={'green'}
|
|
|
|
isSecondary
|
2019-12-23 01:03:44 +00:00
|
|
|
onClick={() => setVisible(true)}
|
|
|
|
>
|
|
|
|
Begin Setup
|
2020-07-03 23:37:26 +01:00
|
|
|
</Button>
|
2019-12-23 01:03:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
;
|
|
|
|
};
|