From 6d0e60e60b3cdf5db795c2cd1336436e908c023f Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Fri, 18 Jun 2021 10:22:24 +0530 Subject: [PATCH] added enter code instead ui --- src/components/TwoFactorModal.tsx | 44 ++++++++++++++++---------- src/utils/strings/englishConstants.tsx | 2 ++ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/components/TwoFactorModal.tsx b/src/components/TwoFactorModal.tsx index 9e449e073..d48a90788 100644 --- a/src/components/TwoFactorModal.tsx +++ b/src/components/TwoFactorModal.tsx @@ -4,13 +4,16 @@ import constants from 'utils/strings/constants'; import MessageDialog from './MessageDialog'; import { DeadCenter } from 'pages/gallery'; import { Button } from 'react-bootstrap'; -import { setupTwoFactor, TwoFactorSector } from 'services/userService'; +import { setupTwoFactor, TwoFactorSecret } from 'services/userService'; import styled from 'styled-components'; import EnteSpinner from './EnteSpinner'; +import { CodeBlock, FreeFlowText } from './RecoveryKeyModal'; +import OtpInput from 'react-otp-input'; const QRCode = styled.img` height:200px; width:200px; +margin:20px; `; interface Props { @@ -25,9 +28,9 @@ enum SetupMode { } function TwoFactorModal({ somethingWentWrong, ...props }: Props) { const [setupMode, setSetupMode] = useState(SetupMode.QR_CODE); - const [twoFactorSecret, setTwoFactorSecret] = useState(null); + const [twoFactorSecret, setTwoFactorSecret] = useState(null); useEffect(() => { - if (!props.show) { + if (!props.show || twoFactorSecret) { return; } const main = async () => { @@ -41,14 +44,14 @@ function TwoFactorModal({ somethingWentWrong, ...props }: Props) { null, disabled: false, variant: 'success', @@ -69,17 +72,26 @@ function TwoFactorModal({ somethingWentWrong, ...props }: Props) { ) : (<>

{constants.TWO_FACTOR_AUTHENTICATION_MANUAL_CODE_INSTRUCTION}

- -
-
- -
+ + {!twoFactorSecret ? : ( + + {twoFactorSecret.secretCode} + + + )} + + - ) - } -
+ )} + {setupMode && -} + />} + ); } export default TwoFactorModal; diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 1196e0944..598cc0f1f 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -402,6 +402,8 @@ const englishConstants = { TWO_FACTOR_AUTHENTICATION_QR_INSTRUCTION: 'please scan QR code below with your favorite authenticator app', ENTER_CODE_MANUALLY: 'enter the code manually', TWO_FACTOR_AUTHENTICATION_MANUAL_CODE_INSTRUCTION: 'please enter this code in your favorite authenticator app', + SCAN_QR_CODE: 'scan QR code instead', + CONTINUE: 'continue', };