parent
e689c05fca
commit
8d17037c0f
1 changed files with 27 additions and 18 deletions
|
@ -14,7 +14,11 @@
|
|||
<label for="field">Field</label>
|
||||
<select id="field">
|
||||
<option value="" selected="selected">Please select an option</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="mail">Email</option>
|
||||
<option value="sshPublicKey">SSH key</option>
|
||||
<option value="cn">First name & Surname</option>
|
||||
<option value="sn">Surname</option>
|
||||
<option value="skDiscord">Discord username</option>
|
||||
</select>
|
||||
<br />
|
||||
<label for="value">Value</label>
|
||||
|
@ -29,25 +33,30 @@
|
|||
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 field = formData.get("field");
|
||||
if (field !== "") {
|
||||
const user = formData.get("user");
|
||||
const pass = formData.get("pass");
|
||||
const newEmail = formData.get("value");
|
||||
const object = {user: user, pass: pass, field: "mail", value: newEmail}
|
||||
const value = formData.get("value");
|
||||
const object = {user: user, pass: pass, field: field, value: value}
|
||||
fetch('https://api.sso.skynet.ie/ldap/update', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(object)
|
||||
}).then(res => {
|
||||
if(res.status === 200) {
|
||||
if (res.status === 200) {
|
||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
|
||||
} 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>";
|
||||
}
|
||||
}).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'>Please select a field to modify</span>";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue