[Modify user] Refactored existing form handling code for what this form will be used for
#1
This commit is contained in:
parent
5235c785b0
commit
13270f2f4e
1 changed files with 13 additions and 19 deletions
|
@ -13,8 +13,6 @@
|
||||||
<input type="password" id="pass" name="pass" /> <br />
|
<input type="password" id="pass" name="pass" /> <br />
|
||||||
<label for="newEmail">New email</label>
|
<label for="newEmail">New email</label>
|
||||||
<input type="email" id="newEmail" name="newPW" /> <br />
|
<input type="email" id="newEmail" name="newPW" /> <br />
|
||||||
<label for="newEmail2">Confirm</label>
|
|
||||||
<input type="email" id="newEmail2" name="newPWConfirm" /> <br />
|
|
||||||
<input type="Submit" value="Submit" />
|
<input type="Submit" value="Submit" />
|
||||||
</form>
|
</form>
|
||||||
<p id="formStatus"></p>
|
<p id="formStatus"></p>
|
||||||
|
@ -31,7 +29,6 @@
|
||||||
const user = formData.get("user");
|
const user = formData.get("user");
|
||||||
const pass = formData.get("pass");
|
const pass = formData.get("pass");
|
||||||
const newEmail = formData.get("newEmail");
|
const newEmail = formData.get("newEmail");
|
||||||
if(newEmail === formData.get("newEmail2")){
|
|
||||||
const object = {user: user, pass: pass, field: "mail", value: newEmail}
|
const object = {user: user, pass: pass, field: "mail", value: newEmail}
|
||||||
fetch('https://api.sso.skynet.ie/ldap/update', {
|
fetch('https://api.sso.skynet.ie/ldap/update', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -45,9 +42,6 @@
|
||||||
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: Failed to communicate to server</span>";
|
||||||
}
|
}
|
||||||
}).catch(() => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</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'>Failure: new passwords don't match</span>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue