From 384f15bc8324084a9ecc118c47ac046e1285bc30 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Tue, 18 Apr 2023 20:38:42 +0000 Subject: [PATCH] navbar bug fix --- src/utils/utils.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 68824fc..ed72eda 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,24 +1,22 @@ -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) { - // key is invalid - handleLogout() - return false - } else { - // key is OK - return true - } - }) + result = await result.json() + if (result.status !== 200) { + // key is invalid + handleLogout() + return false + } else { + // key is OK + return true + } } // The "session" cookie doesn't exist or is invalid return false;