navbar bug fix

main
Gabe Farrell 3 years ago
parent ec09fb8bf1
commit 384f15bc83

@ -1,16 +1,15 @@
export function checkLogin() {
export async function checkLogin() {
var cookies = document.cookie.split(';');
if (getSessionKey() !== null) {
// The "session" cookie exists
fetch('https://api.bb.gabefarrell.com/userinfo', {
let result = await fetch('https://api.bb.gabefarrell.com/userinfo', {
method: 'GET',
headers: {
'x-session-key': getSessionKey(),
},
})
.then(data => data.json())
.then((r) => {
if (r.status !== 200) {
result = await result.json()
if (result.status !== 200) {
// key is invalid
handleLogout()
return false
@ -18,7 +17,6 @@ export function checkLogin() {
// key is OK
return true
}
})
}
// The "session" cookie doesn't exist or is invalid
return false;

Loading…
Cancel
Save