mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-17 03:06:40 -07:00
navbar bug fix
This commit is contained in:
parent
ec09fb8bf1
commit
384f15bc83
1 changed files with 11 additions and 13 deletions
|
|
@ -1,24 +1,22 @@
|
||||||
export function checkLogin() {
|
export async function checkLogin() {
|
||||||
var cookies = document.cookie.split(';');
|
var cookies = document.cookie.split(';');
|
||||||
if (getSessionKey() !== null) {
|
if (getSessionKey() !== null) {
|
||||||
// The "session" cookie exists
|
// The "session" cookie exists
|
||||||
fetch('https://api.bb.gabefarrell.com/userinfo', {
|
let result = await fetch('https://api.bb.gabefarrell.com/userinfo', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'x-session-key': getSessionKey(),
|
'x-session-key': getSessionKey(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(data => data.json())
|
result = await result.json()
|
||||||
.then((r) => {
|
if (result.status !== 200) {
|
||||||
if (r.status !== 200) {
|
// key is invalid
|
||||||
// key is invalid
|
handleLogout()
|
||||||
handleLogout()
|
return false
|
||||||
return false
|
} else {
|
||||||
} else {
|
// key is OK
|
||||||
// key is OK
|
return true
|
||||||
return true
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// The "session" cookie doesn't exist or is invalid
|
// The "session" cookie doesn't exist or is invalid
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue