From 7b7abf5f6785819d1fa72f5ff4556e4ff276ddce Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Wed, 19 Apr 2023 01:12:10 +0000 Subject: [PATCH] fix another navbar bug --- src/utils/utils.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index ed72eda..225f2a8 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,25 +1,28 @@ -export async function checkLogin() { +export function checkLogin() { var cookies = document.cookie.split(';'); if (getSessionKey() !== null) { // The "session" cookie exists - let result = await fetch('https://api.bb.gabefarrell.com/userinfo', { + fetch('https://api.bb.gabefarrell.com/userinfo', { method: 'GET', headers: { 'x-session-key': getSessionKey(), }, }) - result = await result.json() - if (result.status !== 200) { - // key is invalid - handleLogout() - return false - } else { - // key is OK - return true - } + .then(data => data.json()) + .then((result) => { + if (result.status !== 200) { + // key is invalid + handleLogout() + return false + } else { + // key is OK + return true + } + }) + } else { + // The "session" cookie doesn't exist or is invalid + return false; } - // The "session" cookie doesn't exist or is invalid - return false; } export function getSessionKey() {