From a7bde90cb8fbab7e25dd11e13c114a349b6d3946 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 08:59:05 +0000 Subject: [PATCH 01/10] feat: Moved the JS out of the modify page into its own file Related to #9 --- src/index.html | 2 +- src/modify.html | 108 ------------------------------- src/modify/index.html | 62 ++++++++++++++++++ src/modify/modify.js | 58 +++++++++++++++++ src/recovery/password_reset.html | 2 +- src/signup.html | 2 +- 6 files changed, 123 insertions(+), 111 deletions(-) delete mode 100644 src/modify.html create mode 100644 src/modify/index.html create mode 100644 src/modify/modify.js diff --git a/src/index.html b/src/index.html index e1faf23..e3b815e 100644 --- a/src/index.html +++ b/src/index.html @@ -31,7 +31,7 @@

- Account modification + Account modification

Please use this service to modify your user data (email, login ssh key, etc.) diff --git a/src/modify.html b/src/modify.html deleted file mode 100644 index 6bf131a..0000000 --- a/src/modify.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Modify Account - - - - -

- -
-

User modification page

-

- Modify details of your Skynet account. -

-
- - - - - - - - - - - - - - - - - - - - -


- -

-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/modify/index.html b/src/modify/index.html new file mode 100644 index 0000000..80f7534 --- /dev/null +++ b/src/modify/index.html @@ -0,0 +1,62 @@ + + + + + Modify Account + + + + +
+ +
+

User modification page

+

+ Modify details of your Skynet account. +

+
+ + + + + + + + + + + + + + + + + + + + +


+ +

+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/modify/modify.js b/src/modify/modify.js new file mode 100644 index 0000000..131dc80 --- /dev/null +++ b/src/modify/modify.js @@ -0,0 +1,58 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +const dropdown = document.getElementById("dropdown"); +dropdown.addEventListener('onchange', selectField); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const dropdown_value = dropdown.value; + + if (dropdown_value === "") { + document.getElementById('formStatus').innerHTML = "Please select a field to modify"; + return; + } + + const user = formData.get("user"); + const pass = formData.get("pass"); + const value = formData.get("value"); + const body = {auth: {user: user, pass: pass}, field: dropdown_value, value: value}; + + let url = 'https://api.account.skynet.ie/ldap/update'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + document.getElementById('formStatus').innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + document.getElementById('formStatus').innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + document.getElementById('formStatus').innerHTML = `${temp.error}`; + } else { + document.getElementById('formStatus').innerHTML = "Success"; + } +} + +function selectField() { + if (dropdown.value === 'mail') { + document.getElementById('value').type = 'email'; + } else { + document.getElementById('value').type = 'text'; + } +} \ No newline at end of file diff --git a/src/recovery/password_reset.html b/src/recovery/password_reset.html index f23f921..753f33f 100644 --- a/src/recovery/password_reset.html +++ b/src/recovery/password_reset.html @@ -73,7 +73,7 @@ return; } - let data = req.json(); + let data = await req.json(); if (data.result === 'error') { document.getElementById('formStatus').innerHTML = `${data.error}`; } else { diff --git a/src/signup.html b/src/signup.html index 6797d51..ae946fe 100644 --- a/src/signup.html +++ b/src/signup.html @@ -36,7 +36,7 @@

Welcome to Skynet

- If you previously had an account please set your email to be the same as UL Wolves. + If you previously had an account please set your email to be the same as UL Wolves.
If you are a new user, please fill in the form below with the email that you use on ul wolves.

From 019d22695f863a8d53c7b2c6f8e8cb32856e4696 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:08:07 +0000 Subject: [PATCH 02/10] feat: Moved the JS out of the password reset page into its own file Related to #9 --- src/index.html | 2 +- src/password.html | 83 ---------------------------------------- src/password/index.html | 54 ++++++++++++++++++++++++++ src/password/password.js | 49 ++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 84 deletions(-) delete mode 100644 src/password.html create mode 100644 src/password/index.html create mode 100644 src/password/password.js diff --git a/src/index.html b/src/index.html index e3b815e..d00e122 100644 --- a/src/index.html +++ b/src/index.html @@ -23,7 +23,7 @@

- Change Password + Change Password

Please use this service to change your Skynet password diff --git a/src/password.html b/src/password.html deleted file mode 100644 index 9a7e389..0000000 --- a/src/password.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Password reset - - - - -

- -
-

Password Change

-

- Change your Skynet password. -

-
- - - - - - - - - - - - - - - - - - - - -




-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - diff --git a/src/password/index.html b/src/password/index.html new file mode 100644 index 0000000..f6fe8c2 --- /dev/null +++ b/src/password/index.html @@ -0,0 +1,54 @@ + + + + + Password reset + + + + +
+ +
+

Password Change

+

+ Change your Skynet password. +

+
+ + + + + + + + + + + + + + + + + + + + +




+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + diff --git a/src/password/password.js b/src/password/password.js new file mode 100644 index 0000000..e6cc5f2 --- /dev/null +++ b/src/password/password.js @@ -0,0 +1,49 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const user = formData.get("user"); + const pass = formData.get("pass"); + const newPW = formData.get("newPW"); + if (newPW !== formData.get("newPWConfirm")) { + + document.getElementById('formStatus').innerHTML = "Failure: new passwords don't match"; + + return; + } + + const body = {auth: {user: user, pass: pass}, field: "userPassword", value: newPW} + + let url = 'https://api.account.skynet.ie/ldap/update'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } +} \ No newline at end of file From da7adea36e42b3b09eb25c47a8e4ce4a6e7505d9 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:19:04 +0000 Subject: [PATCH 03/10] feat: Moved the JS out of the register page into its own file Related to #9 --- src/register.html | 97 ---------------------------------------- src/register/index.html | 56 +++++++++++++++++++++++ src/register/register.js | 56 +++++++++++++++++++++++ 3 files changed, 112 insertions(+), 97 deletions(-) delete mode 100644 src/register.html create mode 100644 src/register/index.html create mode 100644 src/register/register.js diff --git a/src/register.html b/src/register.html deleted file mode 100644 index e915177..0000000 --- a/src/register.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Skynet Register - - - - -
- -
-

Register

-

- Thank you for signing up for your Skynet account. -
- Please complete the process by filling in the form below. -
- Username is what you want to be known on Skynet as. -
- It must be lowercase, start with a letter and contain only 0-9 a-z and _- -

-
- - - - - - - - - - - - - - - - -


-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/register/index.html b/src/register/index.html new file mode 100644 index 0000000..9cfd259 --- /dev/null +++ b/src/register/index.html @@ -0,0 +1,56 @@ + + + + + Skynet Register + + + + +
+ +
+

Register

+

+ Thank you for signing up for your Skynet account. +
+ Please complete the process by filling in the form below. +
+ Username is what you want to be known on Skynet as. +
+ It must be lowercase, start with a letter and contain only 0-9 a-z and _- +

+
+ + + + + + + + + + + + + + + + +


+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/register/register.js b/src/register/register.js new file mode 100644 index 0000000..2e5f9a8 --- /dev/null +++ b/src/register/register.js @@ -0,0 +1,56 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const pass = formData.get("pass"); + + if (pass !== formData.get("confirm")) { + form_status.innerHTML = `Passwords don't match`; + return; + } + + + const urlParam = new URLSearchParams(new URL(window.location.href).search); + const auth = urlParam.get("auth"); + + // if there is no auth value then return here + if(!auth){ + return; + } + + const user = formData.get("user"); + const body = {auth: auth, user: user, pass: pass}; + + let url = 'https://api.account.skynet.ie/ldap/new/account'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } +} \ No newline at end of file From 68953f0d5fabf84b21661c64f9074bf1a39e7aa2 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:24:48 +0000 Subject: [PATCH 04/10] feat: Moved the JS out of the signup page into its own file Related to #9 --- src/index.html | 2 +- src/signup.html | 84 ------------------------------------------- src/signup/index.html | 59 ++++++++++++++++++++++++++++++ src/signup/signup.js | 45 +++++++++++++++++++++++ 4 files changed, 105 insertions(+), 85 deletions(-) delete mode 100644 src/signup.html create mode 100644 src/signup/index.html create mode 100644 src/signup/signup.js diff --git a/src/index.html b/src/index.html index d00e122..f1acd06 100644 --- a/src/index.html +++ b/src/index.html @@ -15,7 +15,7 @@

- Sign-up + Sign-up

Please use this if you have yet to activate an account on Skynet before. diff --git a/src/signup.html b/src/signup.html deleted file mode 100644 index ae946fe..0000000 --- a/src/signup.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Skynet Sign-up - - - - - -

- -
-

Welcome to Skynet

-

- If you previously had an account please set your email to be the same as UL Wolves. -
- If you are a new user, please fill in the form below with the email that you use on ul wolves. -

-
- -
- -
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/signup/index.html b/src/signup/index.html new file mode 100644 index 0000000..9cb9b5b --- /dev/null +++ b/src/signup/index.html @@ -0,0 +1,59 @@ + + + + + Skynet Sign-up + + + + + +
+ +
+

Welcome to Skynet

+

+ If you previously had an account please set your email to be the same as UL Wolves. +
+ If you are a new user, please fill in the form below with the email that you use on ul wolves. +

+
+ +
+ +
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/signup/signup.js b/src/signup/signup.js new file mode 100644 index 0000000..fcd3a50 --- /dev/null +++ b/src/signup/signup.js @@ -0,0 +1,45 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + //HTML below taken from the W3 schools tutorial () + form_status.innerHTML = "
" + + const formData = new FormData(form); + const email = formData.get("email"); + const body = {email: email}; + + + let url = 'https://api.account.skynet.ie/ldap/new/email'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } + +} \ No newline at end of file From ad55bf81efc3ba3b4a3e1b2d46fd96efae8a5d76 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:28:22 +0000 Subject: [PATCH 05/10] fix: not going to give these their own folder --- src/index.html | 6 +++--- src/{modify/index.html => modify.html} | 6 +++--- src/{modify => }/modify.js | 0 src/{password/index.html => password.html} | 6 +++--- src/{password => }/password.js | 0 src/{register/index.html => register.html} | 6 +++--- src/{register => }/register.js | 0 src/{signup/index.html => signup.html} | 8 ++++---- src/{signup => }/signup.js | 0 9 files changed, 16 insertions(+), 16 deletions(-) rename src/{modify/index.html => modify.html} (88%) rename src/{modify => }/modify.js (100%) rename src/{password/index.html => password.html} (86%) rename src/{password => }/password.js (100%) rename src/{register/index.html => register.html} (87%) rename src/{register => }/register.js (100%) rename src/{signup/index.html => signup.html} (79%) rename src/{signup => }/signup.js (100%) diff --git a/src/index.html b/src/index.html index f1acd06..5741c3b 100644 --- a/src/index.html +++ b/src/index.html @@ -15,7 +15,7 @@

- Sign-up + Sign-up

Please use this if you have yet to activate an account on Skynet before. @@ -23,7 +23,7 @@

- Change Password + Change Password

Please use this service to change your Skynet password @@ -31,7 +31,7 @@

- Account modification + Account modification

Please use this service to modify your user data (email, login ssh key, etc.) diff --git a/src/modify/index.html b/src/modify.html similarity index 88% rename from src/modify/index.html rename to src/modify.html index 80f7534..f201542 100644 --- a/src/modify/index.html +++ b/src/modify.html @@ -3,13 +3,13 @@ Modify Account - - + +

diff --git a/src/modify/modify.js b/src/modify.js similarity index 100% rename from src/modify/modify.js rename to src/modify.js diff --git a/src/password/index.html b/src/password.html similarity index 86% rename from src/password/index.html rename to src/password.html index f6fe8c2..c719e80 100644 --- a/src/password/index.html +++ b/src/password.html @@ -3,13 +3,13 @@ Password reset - - + +
diff --git a/src/password/password.js b/src/password.js similarity index 100% rename from src/password/password.js rename to src/password.js diff --git a/src/register/index.html b/src/register.html similarity index 87% rename from src/register/index.html rename to src/register.html index 9cfd259..6477b0a 100644 --- a/src/register/index.html +++ b/src/register.html @@ -3,13 +3,13 @@ Skynet Register - - + +
diff --git a/src/register/register.js b/src/register.js similarity index 100% rename from src/register/register.js rename to src/register.js diff --git a/src/signup/index.html b/src/signup.html similarity index 79% rename from src/signup/index.html rename to src/signup.html index 9cb9b5b..35417f1 100644 --- a/src/signup/index.html +++ b/src/signup.html @@ -3,8 +3,8 @@ Skynet Sign-up - - + +