From 689340dbb434db89ecbe51c623b028008f3540b6 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 4 Apr 2023 20:31:21 +0100 Subject: [PATCH] Begin implementation of auth page --- auth.html | 41 +++++++++++++++++++++++++++++++++++++++++ js/auth.js | 38 ++++++++++++++++++++++++++++++++++++++ sw.js | 4 +++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 auth.html create mode 100644 js/auth.js diff --git a/auth.html b/auth.html new file mode 100644 index 0000000..ae5d5d1 --- /dev/null +++ b/auth.html @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + OwlBoard + + + +
+
+
+

Registering

+
+ + + + + + + OwlBoard Logo + +
+

+
+ + + + diff --git a/js/auth.js b/js/auth.js new file mode 100644 index 0000000..91a85ea --- /dev/null +++ b/js/auth.js @@ -0,0 +1,38 @@ +const cmd = document.getElementById("cmd") +init(); + +async function sendHome(){ + await delay(2000); + location.replace('/') +} + +async function cmdOut(message) { + html = "

" + message + "

" + cmd.insertAdjacentHTML("beforeend", html) +} + +async function registerKey(key) { + var url = `${window.location.origin}/api/v1/auth/register`; + let res = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + redirect: "follow", + body: JSON.stringify(key) + }) + if (res.JSON['result'] == "ok"){ + return true; + } else { + return false; + } +} + +async function init(){ + cmdOut("Reading registration key"); + const key = await getQuery("key"); + cmdOut(`Key: ${key}`) + cmdOut("Requesting API Key from server"); + let res = await registerKey(key); + console.log(JSON.stringify(res)) +} \ No newline at end of file diff --git a/sw.js b/sw.js index 9324685..08250ac 100644 --- a/sw.js +++ b/sw.js @@ -1,10 +1,11 @@ /* Service Worker */ -const appVersion = "1.2.4" +const appVersion = "1.3.0" const cacheName = `owlboard-${appVersion}`; const cacheIDs = [cacheName]; const cacheFiles = [ "/404.html", + "/auth.html", "/board.html", "/conn-err.html", "/help.html", @@ -28,6 +29,7 @@ const cacheFiles = [ "/js/issue.js", "/js/lib.board.js", "/js/lib.main.js", + "/js/auth.js", "/js/settings.js", "/js/simple-board.js", "/images/icon.svg",