Merge branch '3-new-users-sign-up' into 'main'

Resolve "[New users] Sign-up"

Closes #3

See merge request compsoc1/skynet/ldap/frontend!6
This commit is contained in:
silver 2023-09-03 21:19:30 +00:00
commit 947124c3b6
3 changed files with 90 additions and 2 deletions

View file

@ -7,6 +7,8 @@
</head>
<body>
<h1>Skynet Password Reset & Sign-up service</h1>
<h2><a href="./signup.html">Sign-up Page</a></h2>
<p>Please use this if you have yet to activate an account on Skynet before.</p>
<h2><a href="password.html">Password Reset</a></h2>
<p>Please use this service if you ever forget your skynet password</p>

View file

@ -2,7 +2,7 @@
<html lang="en-ie">
<head>
<meta charset="UTF-8"/>
<title>Skynet Sign-up</title>
<title>Skynet Register</title>
<link rel="icon" type="image/png" href="images/favicon/favicon-16x16.png"/>
</head>
<body>
@ -11,7 +11,7 @@
<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/>
<input type="password" id="pass" name="pass" minlength="8" maxlength="254"/> <br/>
<label for="confirm">Confirm</label>
<input type="password" id="confirm" name="confirm"/>
<input type="Submit" value="Submit"/>

86
src/signup.html Normal file
View file

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en-ie">
<head>
<meta charset="UTF-8"/>
<title>Skynet Sign-up</title>
<link rel="icon" type="image/png" href="images/favicon/favicon-16x16.png"/>
<!-- Below to be put refactored into this page's css file upon completion of that branch -->
<style>
/* Taken from the W3 schools loader tutorial */
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 60px;
height: 60px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 20s linear;
}
/* Safari */
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<h2>Welcome to Skynet</h2>
<p>
Skynet is a server cluster that the UL Computer Society runs. If you previously had an account and need to activate <br />
it please click <a href="./modify.html">here</a> to set a contact email address for your account. IF you are a new <br />
user, please fill in the form below with the email that you use on ul wolves.
</p>
<form id="register">
<label for="mail">Email address</label>
<input type="email" id="mail" name="email"/> <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('register');
formEl.addEventListener('submit', (listener) => formHandler(listener));
function formHandler(listener) {
listener.preventDefault();
//HTML below taken from the W3 schools tutorial ()
document.getElementById('formStatus').innerHTML = "<div class='loader'></div>"
const formData = new FormData(formEl);
const email = formData.get("email");
const object = {email: email};
fetch('https://api.account.skynet.ie/ldap/new/email', {
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>");
}
</script>
</body>
<script>
document.getElementById('year').textContent = new Date().getFullYear().toString()
</script>
</html>