parent
e689c05fca
commit
8d17037c0f
1 changed files with 27 additions and 18 deletions
|
@ -14,7 +14,11 @@
|
||||||
<label for="field">Field</label>
|
<label for="field">Field</label>
|
||||||
<select id="field">
|
<select id="field">
|
||||||
<option value="" selected="selected">Please select an option</option>
|
<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>
|
</select>
|
||||||
<br />
|
<br />
|
||||||
<label for="value">Value</label>
|
<label for="value">Value</label>
|
||||||
|
@ -29,25 +33,30 @@
|
||||||
const formEl = document.getElementById("reset");
|
const formEl = document.getElementById("reset");
|
||||||
formEl.addEventListener('submit', (listener) => formHandler(listener));
|
formEl.addEventListener('submit', (listener) => formHandler(listener));
|
||||||
|
|
||||||
function formHandler(listener){
|
function formHandler(listener) {
|
||||||
listener.preventDefault();
|
listener.preventDefault();
|
||||||
const formData = new FormData(formEl);
|
const formData = new FormData(formEl);
|
||||||
const user = formData.get("user");
|
const field = formData.get("field");
|
||||||
const pass = formData.get("pass");
|
if (field !== "") {
|
||||||
const newEmail = formData.get("value");
|
const user = formData.get("user");
|
||||||
const object = {user: user, pass: pass, field: "mail", value: newEmail}
|
const pass = formData.get("pass");
|
||||||
fetch('https://api.sso.skynet.ie/ldap/update', {
|
const value = formData.get("value");
|
||||||
method: 'POST',
|
const object = {user: user, pass: pass, field: field, value: value}
|
||||||
body: JSON.stringify(object)
|
fetch('https://api.sso.skynet.ie/ldap/update', {
|
||||||
}).then(res => {
|
method: 'POST',
|
||||||
if(res.status === 200) {
|
body: JSON.stringify(object)
|
||||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
|
}).then(res => {
|
||||||
} else if (res.status === 500){
|
if (res.status === 200) {
|
||||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
|
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
|
||||||
} else {
|
} else if (res.status === 500) {
|
||||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Failed to communicate to server</span>";
|
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
|
||||||
}
|
} else {
|
||||||
}).catch(() => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>");
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue