Refactored code to standard using IDE
Signed-off-by: Eoghan Conlon <eoghanconlon73@skynet.ie>
This commit is contained in:
parent
a6104b0565
commit
d19fcb9c10
1 changed files with 51 additions and 51 deletions
|
@ -5,50 +5,50 @@
|
|||
<title>Password recovery</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Password Recovery</h1>
|
||||
<p>Please reset your password below</p>
|
||||
<form id="reset">
|
||||
<h1>Password Recovery</h1>
|
||||
<p>Please reset your password below</p>
|
||||
<form id="reset">
|
||||
<label for="pass1">Password</label>
|
||||
<input type="password" id="pass1" name="password" /> <br />
|
||||
<input type="password" id="pass1" name="password"/> <br/>
|
||||
<label for="pass2">Confirm</label>
|
||||
<input type="password" id="pass2" name="confirm" /> <br />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
<p id="formStatus"></p>
|
||||
<footer>
|
||||
<input type="password" id="pass2" name="confirm"/> <br/>
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
<p id="formStatus"></p>
|
||||
<footer>
|
||||
UL Computer Society 2023-<span id="year">2023</span>
|
||||
</footer>
|
||||
<script>
|
||||
</footer>
|
||||
<script>
|
||||
document.getElementById('year').textContent = new Date().getFullYear().toString()
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
<script>
|
||||
const formEl = document.getElementById("reset");
|
||||
formEl.addEventListener('submit', (listener) => formHandler(listener));
|
||||
|
||||
function formHandler(listener){
|
||||
function formHandler(listener) {
|
||||
listener.preventDefault();
|
||||
const formData = new FormData(formEl);
|
||||
const pass = formData.get("password");
|
||||
if(pass === formData.get("confirm")){
|
||||
if (pass === formData.get("confirm")) {
|
||||
const url = new URL(window.location.href);
|
||||
const urlParam = new URLSearchParams(url.search);
|
||||
const auth = urlParam.get("auth");
|
||||
const object = {auth: auth, pass: pass };
|
||||
const object = {auth: auth, pass: pass};
|
||||
fetch("https://api.account.skynet.ie/ldap/recover/auth", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(object),
|
||||
mode: "cors"
|
||||
}).then(res => {
|
||||
if(res.status === 200){
|
||||
if (res.status === 200) {
|
||||
return res.json();
|
||||
} else if (res.status === 500){
|
||||
} 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>";
|
||||
}
|
||||
}).then(temp => {
|
||||
if(temp){
|
||||
if(temp.result === 'error'){
|
||||
if (temp) {
|
||||
if (temp.result === 'error') {
|
||||
document.getElementById('formStatus').innerHTML = `<span style='background-color: red; color: white'>${temp.error}</span>`;
|
||||
} else {
|
||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
|
||||
|
@ -59,6 +59,6 @@
|
|||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Passwords don't match</span>";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue