diff --git a/src/pages/Home.js b/src/pages/Home.js index 9b81d2c..ec87bf9 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -10,11 +10,10 @@ const Profile = () => { const [twoFactorError, set2FAError] = useState(null); const [qr, setQr] = useState(null); - const enable2FA = async () => { + const displayQr = async () => { const response = await get('/api/user/2fa'); if (response.status !== 200) return set2FAError(response.message); - setQr(response.data); - console.log(qr); + setQr(response.message); }; const authCodeRef = useRef(); @@ -24,10 +23,31 @@ const Profile = () => { if(response.status !== 200) return set2FAError(response.message); }; + const codeRef = useRef(); + const submitCode = async () => { + + const code = codeRef.current.value; + if (!code) return; + const response = await post('/api/user/2fa/verify', { code }); + if (response.status !== 200) return set2FAError(response.message); + + }; + return
+
+

Profile

+ +

Profile Picture

+ +
+ + +
+
+

Settings

@@ -49,17 +69,24 @@ const Profile = () => {

Two Factor

+ {twoFactorError &&

{twoFactorError}

} {!user.twoFactor ?
- + {qr ? +
+ +
+ + +
+
: + }
:
} - {qr && } -
; };