80 lines
3.3 KiB
HTML
80 lines
3.3 KiB
HTML
<!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"/>
|
|
<link rel="stylesheet" type="text/css" href="stylesheets/index.css"/>
|
|
</head>
|
|
<body>
|
|
<div id="title">
|
|
<a href="./"><img src="images/sharky_vector_svg.svg" alt="Picture of Sharky, the mascot of skynet" width="145"
|
|
height="81.56"/> </a>
|
|
<h1>Skynet Password Reset & Sign-up service</h1>
|
|
</div>
|
|
<div class="boxes">
|
|
<h2>Password Change</h2>
|
|
<p>Please use this page to change your Skynet password.</p>
|
|
<form id="reset">
|
|
<table id="table">
|
|
<tr>
|
|
<td><label for="user">Username</label></td>
|
|
<td><input type="text" id="user" name="user"/> <br/></td>
|
|
</tr>
|
|
<tr>
|
|
<td><label for="pass">Old Password</label></td>
|
|
<td><input type="password" id="pass" name="pass"/> <br/></td>
|
|
</tr>
|
|
<tr>
|
|
<td><label for="newPW1">New Password</label></td>
|
|
<td><input type="password" id="newPW1" name="newPW"/> <br/></td>
|
|
</tr>
|
|
<tr>
|
|
<td><label for="newPW2">Confirm</label></td>
|
|
<td><input type="password" id="newPW2" name="newPWConfirm"/> <br/></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2"><input type="Submit" value="Submit"/></td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<p id="formStatus"></p>
|
|
</div>
|
|
<footer>
|
|
UL Computer Society 2023-<span id="year">2023</span>
|
|
</footer>
|
|
<script>
|
|
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.account.skynet.ie/ldap/update', {
|
|
method: 'POST',
|
|
body: JSON.stringify(object),
|
|
mode: "cors"
|
|
}).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>";
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
<script>
|
|
document.getElementById('year').textContent = new Date().getFullYear().toString();
|
|
</script>
|
|
</html>
|