aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/login.js
diff options
context:
space:
mode:
authorNidboj132 <lol2s@vp.plm>2023-05-06 17:51:01 +0200
committerNidboj132 <lol2s@vp.plm>2023-05-06 17:51:01 +0200
commit9d532e86571453c5db59979416fc0428f2e80a22 (patch)
treef3f995596c743742211731d1dedef64f45029de7 /frontend/src/components/login.js
parentlogin test (diff)
downloadlphub-9d532e86571453c5db59979416fc0428f2e80a22.tar.gz
lphub-9d532e86571453c5db59979416fc0428f2e80a22.tar.bz2
lphub-9d532e86571453c5db59979416fc0428f2e80a22.zip
login test
Diffstat (limited to 'frontend/src/components/login.js')
-rw-r--r--frontend/src/components/login.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js
index 507cf5b..558bc8f 100644
--- a/frontend/src/components/login.js
+++ b/frontend/src/components/login.js
@@ -16,13 +16,15 @@ function logout() {
16 setToken(null) 16 setToken(null)
17 window.location.href="/" 17 window.location.href="/"
18} 18}
19
20const [token, setToken] = React.useState(null); 19const [token, setToken] = React.useState(null);
21const isLoggedIn = token !== null; 20const isLoggedIn = token !== null;
22React.useEffect(() => { 21React.useEffect(() => {
23 fetch(`/api/v1/token`) 22 fetch(`/api/v1/token`)
24 .then(r => {console.log(r)}) 23 .then(r => r.json())
25 .then(d => {setToken(d.data.token);console.log(d)}) 24 .then(d => {
25 setToken(d.data.token);
26 console.log(d);
27 })
26 }, []); 28 }, []);
27 29
28const [profile, setProfile] = React.useState(); 30const [profile, setProfile] = React.useState();
@@ -32,10 +34,11 @@ React.useEffect(() => {
32 'Content-Type': 'application/json', 34 'Content-Type': 'application/json',
33 Authorization: token 35 Authorization: token
34 }}) 36 }})
35 .then(r => {console.log(r)}) 37 .then(r => r.json())
36 .then(d => {setProfile(d);console.log(d)}) 38 .then(d => {setProfile(d);console.log(d)})
37 }, []); 39 }, []);
38 40
41
39return ( 42return (
40 <> 43 <>
41 {isLoggedIn ? ( 44 {isLoggedIn ? (