pis #2

Merged
fred.boniface merged 76 commits from pis into main 2023-05-06 21:53:45 +01:00
Showing only changes of commit c7f34c3621 - Show all commits

View File

@ -1,5 +1,12 @@
const cmd = document.getElementById("cmd") /*
init(); Auth process: User Requests Key => Server emails key to user =>
user opens link on auth.html =>
website POSTs key to server => Server checks validity =>
Server responds with the users auth key =>
auth.js adds this to localStorage
*/
const cmd = document.getElementById("cmd") // Assign element to const
init(); // Run init function
async function sendHome(){ async function sendHome(){
await delay(2000); await delay(2000);
@ -11,9 +18,9 @@ async function cmdOut(message) {
cmd.insertAdjacentHTML("beforeend", html) cmd.insertAdjacentHTML("beforeend", html)
} }
async function registerKey(key) { async function registerKey(key) { // Posts key to server and listens for response.
var url = `${window.location.origin}/api/v1/auth/register`; var url = `${window.location.origin}/api/v1/auth/register`;
let res = await fetch(url, { let res = await fetch(url, { // The response will contain the UUID which will be registered
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@ -28,7 +35,7 @@ async function registerKey(key) {
} }
} }
async function init(){ async function init(){ // Reads registration key from query, and calls registerKey(key)
cmdOut("Reading registration key"); cmdOut("Reading registration key");
const key = await getQuery("key"); const key = await getQuery("key");
cmdOut(`Key: ${key}`) cmdOut(`Key: ${key}`)