[Refactoring] Better naming scheme

This commit is contained in:
eoghan.conlon 2023-07-29 22:58:35 +01:00
parent 0f557ab420
commit 290ba80627
7 changed files with 115 additions and 113 deletions

View file

@ -1,27 +0,0 @@
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 newEmail = formData.get("newEmail");
if(newEmail === formData.get("newEmail2")){
const object = {user: user, pass: pass, field: "mail", value: newEmail}
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>";
}
}

View file

@ -1,29 +0,0 @@
<!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">Password</label>
<input type="password" id="pass" name="pass" /> <br />
<label for="newEmail">New email</label>
<input type="email" id="newEmail" name="newPW" /> <br />
<label for="newEmail2">Confirm</label>
<input type="email" id="newEmail2" 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>

View file

@ -1,27 +0,0 @@
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>";
}
}

View file

@ -1,29 +0,0 @@
<!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>

View file

@ -8,7 +8,7 @@
<h1>Skynet Password Reset & Sign-up service</h1> <h1>Skynet Password Reset & Sign-up service</h1>
<h2><a href="SignUp/index.html"> Account Signup</a></h2> <h2><a href="SignUp/index.html"> Account Signup</a></h2>
<p>Please use this service if you haven't gotten a skynet account already</p> <p>Please use this service if you haven't gotten a skynet account already</p>
<h2><a href="PassReset/index.html">Password Reset</a></h2> <h2><a href="password.html">Password Reset</a></h2>
<p>Please use this service if you ever forget your skynet password</p> <p>Please use this service if you ever forget your skynet password</p>
<!--testing2--> <!--testing2-->

57
src/modify.html Normal file
View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en-ie">
<head>
<meta charset="UTF-8" />
<title>Email change</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">Password</label>
<input type="password" id="pass" name="pass" /> <br />
<label for="newEmail">New email</label>
<input type="email" id="newEmail" name="newPW" /> <br />
<label for="newEmail2">Confirm</label>
<input type="email" id="newEmail2" 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>
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 newEmail = formData.get("newEmail");
if(newEmail === formData.get("newEmail2")){
const object = {user: user, pass: pass, field: "mail", value: newEmail}
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>";
}
}
</script>
</body>
<script>
document.getElementById('year').textContent = new Date().getFullYear().toString();
</script>
</html>

57
src/password.html Normal file
View file

@ -0,0 +1,57 @@
<!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>
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>";
}
}
</script>
</body>
<script>
document.getElementById('year').textContent = new Date().getFullYear().toString();
</script>
</html>