From dbc0a878df6d20e2a7306d06602a44f6046628fa Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Wed, 8 Sep 2021 20:16:37 +0900 Subject: [PATCH] wowwwwwww --- src/App.js | 29 ++++++++++++++++++++++------- src/DEFAULTS.js | 2 +- src/TestHeader.js | 31 +++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/App.js b/src/App.js index e2a519b..79d5544 100644 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,6 @@ import md5 from 'md5'; const cookies = require('cookie-handler'); - const axios = require('axios'); const parse = require('csv-parse/lib/sync') @@ -864,8 +863,8 @@ function App() { const [DATAID,setDATAID] = useState({GetData:()=>{}}) const [update,setUpdate] = useState(false) - const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") - const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") + const [LOGGEDINUSER,setLOGGEDINUSER] = useState(cookies.get("username")) + const [LOGGEDINHASH,setLOGGEDINHASH] = useState(cookies.get("password")) const PANELPATHWBUILD = process.env.PUBLIC_URL+"/test/:BUILDID" const PANELPATH = process.env.PUBLIC_URL+"/test" @@ -919,7 +918,11 @@ function App() { - + - + {APP_TITLE+" - Login"} - + {APP_TITLE+" - Register"} - + diff --git a/src/DEFAULTS.js b/src/DEFAULTS.js index cb75e80..edf51a7 100644 --- a/src/DEFAULTS.js +++ b/src/DEFAULTS.js @@ -2,7 +2,7 @@ const NICONICONII = process.env.PUBLIC_URL+"/icons/nicodotpng.png.png" function DisplayIcon(icon) { //console.log(icon) - return icon&&icon.length>0?process.env.PUBLIC_URL+icon:NICONICONII + return icon&&icon.length>0?icon.includes("http")?icon:process.env.PUBLIC_URL+icon:NICONICONII } export {NICONICONII,DisplayIcon}; \ No newline at end of file diff --git a/src/TestHeader.js b/src/TestHeader.js index 713062d..50fd0ad 100644 --- a/src/TestHeader.js +++ b/src/TestHeader.js @@ -1,6 +1,29 @@ -import React from 'react'; +import React, { useEffect,useState } from 'react'; +import { DisplayIcon } from './DEFAULTS'; + + +const axios = require('axios'); +const cookies = require('cookie-handler'); + +function TestHeader(p) { + + const [avatar,setAvatar] = useState(undefined); + const [username,setUsername] = useState(undefined); + + useEffect(()=>{ + axios.post(p.BACKENDURL+"/validUser",{ + username:p.LOGGEDINUSER, + password:p.LOGGEDINHASH, + recoveryhash:cookies.get("userID") + }) + .then((data)=>{ + if (data.data.verified) { + setAvatar(data.data.avatar) + setUsername(p.LOGGEDINUSER) + } + })} + ,[]) -function TestHeader() { return (
@@ -13,8 +36,8 @@ function TestHeader() {
-
. Guest   ···
-
.
+
. {username??"Guest"}   ···
+
.