Code clean-up
Signed-off-by: Eoghan Conlon <eoghanconlon73@skynet.ie>
This commit is contained in:
parent
de2dc0b459
commit
16e6ce9a98
1 changed files with 49 additions and 49 deletions
|
@ -5,29 +5,29 @@
|
|||
<title>SSH key recovery</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SSH key recovery</h1>
|
||||
<form id="form">
|
||||
<h1>SSH key recovery</h1>
|
||||
<form id="form">
|
||||
<label for="user">Username</label>
|
||||
<input type="text" id="user" name="user" /> <br />
|
||||
<input type="text" id="user" name="user"/> <br/>
|
||||
<label for="mail">Email</label>
|
||||
<input type="email" id="mail" name="mail" /> <br />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
<p id="formStatus"></p>
|
||||
<footer>
|
||||
<input type="email" id="mail" name="mail"/> <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("form");
|
||||
formEl.addEventListener('submit', formHandler);
|
||||
|
||||
function formHandler(listener){
|
||||
function formHandler(listener) {
|
||||
listener.preventDefault();
|
||||
const formData = new FormData(formEl);
|
||||
const object = { user: formData.get('user'), email: formData.get('mail')};
|
||||
const object = {user: formData.get('user'), email: formData.get('mail')};
|
||||
fetch('https://api.account.skynet.ie/ldap/recover/ssh/request', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(object),
|
||||
|
@ -40,25 +40,25 @@
|
|||
});
|
||||
}
|
||||
|
||||
function status(res){
|
||||
if(res.status === 200){
|
||||
function status(res) {
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
function json(temp){
|
||||
if(temp){
|
||||
if(temp.result === 'error'){
|
||||
function json(temp) {
|
||||
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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue