diff --git a/package.json b/package.json index 462b95054..2e3d7a14f 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "i18next-chained-backend": "^2.0.0", "i18next-localstorage-backend": "^3.0.0", "i18next-xhr-backend": "^3.2.2", + "qrcode.react": "^1.0.1", "query-string": "^6.7.0", "react": "^16.13.1", "react-copy-to-clipboard": "^5.0.2", diff --git a/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx b/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx index 0b0db4d77..9246707f0 100644 --- a/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx +++ b/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx @@ -7,53 +7,29 @@ import tw from 'twin.macro'; import Button from '@/components/elements/Button'; export default () => { - const user = useStoreState((state: ApplicationStore) => state.user.data!); const [ visible, setVisible ] = useState(false); + const isEnabled = useStoreState((state: ApplicationStore) => state.user.data!.useTotp); - return user.useTotp ? + return (
- Two-factor authentication is currently enabled on your account. + {isEnabled ? + 'Two-factor authentication is currently enabled on your account.' + : + 'You do not currently have two-factor authentication enabled on your account. Click the button below to begin configuring it.' + }
- You do not currently have two-factor authentication enabled on your account. Click - the button below to begin configuring it. -
-- Two-factor authentication has been enabled on your account. Should you loose access to - this device you'll need to use one of the codes displayed below in order to access your - account. -
-- These codes will not be displayed again. Please take note of them now - by storing them in a secure repository such as a password manager. -
-
- {recoveryTokens.map(token => {token}
)}
-
- + Two-factor authentication has been enabled on your account. Should you loose access to + this device you'll need to use one of the codes displayed below in order to access your + account. +
++ These codes will not be displayed again. Please take note of them now + by storing them in a secure repository such as a password manager. +
+
+ {recoveryTokens.map(token => {token}
)}
+
+ (modalProps?: ExtendedModalProps | ((props: P) => ExtendedModalProps)): ExtendedComponentType
{ +function asModal
(modalProps?: SettableModalProps | ((props: P) => SettableModalProps)): ExtendedComponentType
{ return function (Component) { return class extends React.PureComponent
{ static displayName = `asModal(${Component.displayName})`; @@ -30,54 +31,64 @@ function asModal
(modalProps?: ExtendedModalProps | ((props: P
render: props.visible,
visible: props.visible,
showSpinnerOverlay: undefined,
+ propOverrides: {},
};
}
- get modalProps () {
+ get computedModalProps (): Readonly }
+ */
componentDidUpdate (prevProps: Readonly ) {
if (prevProps.visible && !this.props.visible) {
- // noinspection JSPotentiallyInvalidUsageOfThis
this.setState({ visible: false, showSpinnerOverlay: false });
} else if (!prevProps.visible && this.props.visible) {
- // noinspection JSPotentiallyInvalidUsageOfThis
this.setState({ render: true, visible: true });
}
+ if (!this.state.render) {
+ this.setState({ propOverrides: {} });
+ }
}
dismiss = () => this.setState({ visible: false });
- toggleSpinner = (value?: boolean) => this.setState({ showSpinnerOverlay: value });
+ setPropOverrides: ModalContextValues['setPropOverrides'] = value => this.setState(state => ({
+ propOverrides: !value ? {} : (typeof value === 'function' ? value(state.propOverrides) : value),
+ }));
+ /**
+ * @this {React.PureComponent }
+ */
render () {
+ if (!this.state.render) return null;
+
return (
- this.state.render ?
-