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