[Email Change] Copying files from password reset #1
This commit is contained in:
parent
9b4a6cd34c
commit
693acc7946
2 changed files with 56 additions and 0 deletions
27
src/EmailChange/formHandler.js
Normal file
27
src/EmailChange/formHandler.js
Normal file
|
@ -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 = "<span style='background-color: green; color: white'>Success</span>";
|
||||
} else if (res.status === 500){
|
||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
|
||||
} else {
|
||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Failed to communicate to server</span>";
|
||||
}
|
||||
}).catch(() => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>");
|
||||
} else {
|
||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: new passwords don't match</span>";
|
||||
}
|
||||
}
|
29
src/EmailChange/index.html
Normal file
29
src/EmailChange/index.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-ie">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Password reset</title>
|
||||
<link rel="icon" type="image/png" href="../images/favicon/favicon-16x16.png" />
|
||||
</head>
|
||||
<body>
|
||||
<form id="reset">
|
||||
<label for="user">Username</label>
|
||||
<input type="text" id="user" name="user" /> <br />
|
||||
<label for="pass">Old Password</label>
|
||||
<input type="password" id="pass" name="pass" /> <br />
|
||||
<label for="newPW1">New Password</label>
|
||||
<input type="password" id="newPW1" name="newPW" /> <br />
|
||||
<label for="newPW2">Confirm</label>
|
||||
<input type="password" id="newPW2" name="newPWConfirm" /> <br />
|
||||
<input type="Submit" value="Submit" />
|
||||
</form>
|
||||
<p id="formStatus"></p>
|
||||
<footer>
|
||||
UL Computer Society 2023-<span id="year">2023</span>
|
||||
</footer>
|
||||
<script src="formHandler.js"></script>
|
||||
</body>
|
||||
<script>
|
||||
document.getElementById('year').textContent = new Date().getFullYear().toString();
|
||||
</script>
|
||||
</html>
|
Loading…
Reference in a new issue