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.