mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-17 03:06:40 -07:00
abandoned valid login check
This commit is contained in:
parent
7b7abf5f67
commit
d2312648e7
1 changed files with 2 additions and 19 deletions
|
|
@ -1,26 +1,9 @@
|
||||||
export function checkLogin() {
|
export function checkLogin() {
|
||||||
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', {
|
return true
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'x-session-key': getSessionKey(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(data => data.json())
|
|
||||||
.then((result) => {
|
|
||||||
if (result.status !== 200) {
|
|
||||||
// key is invalid
|
|
||||||
handleLogout()
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
// key is OK
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
// The "session" cookie doesn't exist or is invalid
|
// The "session" cookie doesn't exist
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue