From 589a58d458d7900f923b1b708cf500798a7c8650 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Fri, 7 Apr 2023 22:45:31 +0100 Subject: [PATCH] Minor adjustments --- js/auth.js | 20 ++++++++++++++------ js/lib.main.js | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/js/auth.js b/js/auth.js index 33e3d95..0ed6bb4 100644 --- a/js/auth.js +++ b/js/auth.js @@ -30,7 +30,7 @@ async function registerKey(key) { // Posts key to server and listens for respons }) const data = await res.json(); return res.status === 201 - ? (localStorage.setItem("uuid", data.uuid), true) + ? (localStorage.setItem("uuid", data.api_key), true) : false; } @@ -47,16 +47,24 @@ async function checkAuth(key) { } async function init(){ // Reads registration key from query, and calls registerKey(key) - cmdOut("Reading registration key"); + cmdOut("Reading authorisation code"); const key = await getQuery("key"); - cmdOut(`Temporary: ${key}`) cmdOut("Requesting API Key from server"); if (!await registerKey(key)) { cmdOut("Failed to register key") hideLoading() return } - await checkAuth(localStorage.getItem("uuid")) - ? cmdOut("Authentication succesful") - : cmdOut("Authentication failed") + showLoading() + if (! await checkAuth(localStorage.getItem("uuid"))) { + cmdOut("Authentication Check failed") + cmdOut("Please try again") + hideLoading() + await delay(2000) + location.replace("./") + } + hideLoading(); + cmdOut("Authentication succesful") + await delay(2000) + location.replace("./") } \ No newline at end of file diff --git a/js/lib.main.js b/js/lib.main.js index f9544e2..9cc9747 100644 --- a/js/lib.main.js +++ b/js/lib.main.js @@ -87,7 +87,7 @@ async function hideLoading() { /* DEPRECIATED: Alias for hideLoading() - Marked for removal*/ async function clearLoading() { log("Depreciated function called - clearLoading() - Alias to hideLoading()", "WARN") - await hideLoading(); + hideLoading(); } async function showLoading() {