More comments to clear my confused brain

This commit is contained in:
Fred Boniface 2023-04-05 16:27:49 +01:00
parent 632031d453
commit c7f34c3621

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(){
await delay(2000);
@ -11,9 +18,9 @@ async function cmdOut(message) {
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`;
let res = await fetch(url, {
let res = await fetch(url, { // The response will contain the UUID which will be registered
method: "POST",
headers: {
"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");
const key = await getQuery("key");
cmdOut(`Key: ${key}`)