diff --git a/src/EmailChange/formHandler.js b/src/EmailChange/formHandler.js new file mode 100644 index 0000000..9ac1bba --- /dev/null +++ b/src/EmailChange/formHandler.js @@ -0,0 +1,27 @@ +const formEl = document.getElementById("reset"); +formEl.addEventListener('submit', (listener) => formHandler(listener)); + +function formHandler(listener){ + listener.preventDefault(); + const formData = new FormData(formEl); + const user = formData.get("user"); + const pass = formData.get("pass"); + const newPW = formData.get("newPW"); + if(newPW === formData.get("newPWConfirm")){ + const object = {user: user, pass: pass, field: "userPassword", value: newPW} + fetch('https://api.sso.skynet.ie/ldap/update', { + method: 'POST', + body: JSON.stringify(object) + }).then(res => { + if(res.status === 200) { + document.getElementById('formStatus').innerHTML = "Success"; + } else if (res.status === 500){ + document.getElementById('formStatus').innerHTML = "Failure"; + } else { + document.getElementById('formStatus').innerHTML = "Failure: Failed to communicate to server"; + } + }).catch(() => document.getElementById('formStatus').innerHTML = "Please try again"); + } else { + document.getElementById('formStatus').innerHTML = "Failure: new passwords don't match"; + } +} \ No newline at end of file diff --git a/src/EmailChange/index.html b/src/EmailChange/index.html new file mode 100644 index 0000000..9e88441 --- /dev/null +++ b/src/EmailChange/index.html @@ -0,0 +1,29 @@ + + + + + Password reset + + + +
+ +
+ +
+ +
+ +
+ +
+

+ + + + + \ No newline at end of file