Fix. Password recovery page has standardized html through ide tool

This commit is contained in:
eoghan.conlon 2023-08-08 19:18:58 +01:00
parent 4915d83035
commit 6ac9c08148

View file

@ -12,10 +12,10 @@
<option value="" selected="selected">Please select an option</option>
<option value="user">Username</option>
<option value="email">Email</option>
</select> <br />
</select> <br/>
<label for="value">Value</label>
<input type="text" id="value" name="value" /> <br />
<input type="submit" value="submit" />
<input type="text" id="value" name="value"/> <br/>
<input type="submit" value="submit"/>
</form>
<p id="formStatus"></p>
<footer>
@ -25,42 +25,42 @@
const formEl = document.getElementById('recovery');
formEl.addEventListener('submit', (listener) => formHandler(listener));
function formHandler(listener){
function formHandler(listener) {
listener.preventDefault();
const option = document.getElementById('options').value.toString();
if(option === ''){
if (option === '') {
alert("Need to implement this");
} else {
const formData = new FormData(formEl);
const value = formData.get('value');
let object;
if (option === 'email'){
object = { email: value };
if (option === 'email') {
object = {email: value};
} else {
object = { user: value };
object = {user: value};
}
fetch('https://api.account.skynet.ie/ldap/recover/password', {
method: 'POST',
body: JSON.stringify(object),
mode: "cors"
}).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>";
})
});
}
}
function selectField(){
function selectField() {
const field = document.getElementById('options').value;
const inputEl = document.getElementById('value');
if(field === "email"){
if (field === "email") {
inputEl.type = 'email';
} else {
inputEl.type = 'text';