ldap_frontend/src/signup.html

54 lines
2.2 KiB
HTML
Raw Normal View History

<!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"/>
</head>
<body>
2023-08-07 18:19:36 +01:00
<h2>Welcome to Skynet</h2>
<p>
2023-08-07 19:14:11 +01:00
Skynet is a server cluster that the UL Computer Society runs. If you previously had an account and need to activate
it
please click <a href="./modify.html">here</a> to set a contact email address for your account. IF you are a new
user,
2023-08-07 18:19:36 +01:00
please fill in the form below with the email that you use on ul wolves.
</p>
2023-08-07 18:19:15 +01:00
<form id="register">
<label for="mail">Email address</label>
2023-08-07 19:14:11 +01:00
<input type="email" id="mail" name="email"/> <br/>
<input type="submit" value="Submit"/>
2023-08-07 18:19:15 +01:00
</form>
2023-08-07 18:49:15 +01:00
<p id="formStatus"></p>
<footer>
UL Computer Society 2023-<span id="year">2023</span>
</footer>
2023-08-07 18:23:20 +01:00
<script>
const formEl = document.getElementById('register');
formEl.addEventListener('submit', (listener) => formHandler(listener));
2023-08-07 19:14:11 +01:00
function formHandler(listener) {
2023-08-07 18:23:20 +01:00
listener.preventDefault();
2023-08-07 18:27:45 +01:00
const formData = new FormData(formEl);
const email = formData.get("email");
const object = {email: email};
2023-08-07 18:49:15 +01:00
fetch('https://api.account.skynet.ie/ldap/new/email', {
method: 'POST',
body: JSON.stringify(object),
mode: "cors"
}).then(res => {
2023-08-07 19:14:11 +01:00
if (res.status === 200) {
2023-08-07 18:49:15 +01:00
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>");
2023-08-07 18:23:20 +01:00
}
</script>
2023-08-07 18:49:15 +01:00
</body>
<script>
document.getElementById('year').textContent = new Date().getFullYear().toString()
</script>
</html>