From 2cf359fa2417a56e97314de49ec324934acf5d9c Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 25 Nov 2022 20:57:33 +0200 Subject: [PATCH] profile settings WIP --- src/pages/Home.js | 83 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/src/pages/Home.js b/src/pages/Home.js index c87a5f1..9b81d2c 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -1,16 +1,81 @@ -import React from "react"; +import React, { useRef, useState } from "react"; +import { Route, Routes } from "react-router"; import '../css/pages/Home.css'; -import { get } from "../util/Util"; +import { useLoginContext } from "../structures/UserContext"; +import { get, post } from "../util/Util"; -const Home = () => { +const Profile = () => { - return
- + const [user] = useLoginContext(); + const [twoFactorError, set2FAError] = useState(null); + + const [qr, setQr] = useState(null); + const enable2FA = async () => { + const response = await get('/api/user/2fa'); + if (response.status !== 200) return set2FAError(response.message); + setQr(response.data); + console.log(qr); + }; + + const authCodeRef = useRef(); + const disable2FA = async () => { + const code = authCodeRef.current.value; + const response = await post('/api/user/2fa/disable', {code}); + if(response.status !== 200) return set2FAError(response.message); + }; + + return
+
+ +
+
+

Settings

+ +

ID: {user.id}

+ +
+ + + + + + + + + + + + +
+ +

Two Factor

+ {!user.twoFactor ? +
+ +
: +
+ +
+ } + + {qr && } + +
; }; +const Main = () => { + + return
+ +
; +}; + +const Home = () => { + + return + } /> + } /> + ; +}; export default Home; \ No newline at end of file