Fix. Password recovery page has standardized html through ide tool
This commit is contained in:
parent
4915d83035
commit
6ac9c08148
1 changed files with 13 additions and 13 deletions
|
@ -12,10 +12,10 @@
|
||||||
<option value="" selected="selected">Please select an option</option>
|
<option value="" selected="selected">Please select an option</option>
|
||||||
<option value="user">Username</option>
|
<option value="user">Username</option>
|
||||||
<option value="email">Email</option>
|
<option value="email">Email</option>
|
||||||
</select> <br />
|
</select> <br/>
|
||||||
<label for="value">Value</label>
|
<label for="value">Value</label>
|
||||||
<input type="text" id="value" name="value" /> <br />
|
<input type="text" id="value" name="value"/> <br/>
|
||||||
<input type="submit" value="submit" />
|
<input type="submit" value="submit"/>
|
||||||
</form>
|
</form>
|
||||||
<p id="formStatus"></p>
|
<p id="formStatus"></p>
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -25,42 +25,42 @@
|
||||||
const formEl = document.getElementById('recovery');
|
const formEl = document.getElementById('recovery');
|
||||||
formEl.addEventListener('submit', (listener) => formHandler(listener));
|
formEl.addEventListener('submit', (listener) => formHandler(listener));
|
||||||
|
|
||||||
function formHandler(listener){
|
function formHandler(listener) {
|
||||||
listener.preventDefault();
|
listener.preventDefault();
|
||||||
const option = document.getElementById('options').value.toString();
|
const option = document.getElementById('options').value.toString();
|
||||||
if(option === ''){
|
if (option === '') {
|
||||||
alert("Need to implement this");
|
alert("Need to implement this");
|
||||||
} else {
|
} else {
|
||||||
const formData = new FormData(formEl);
|
const formData = new FormData(formEl);
|
||||||
const value = formData.get('value');
|
const value = formData.get('value');
|
||||||
let object;
|
let object;
|
||||||
if (option === 'email'){
|
if (option === 'email') {
|
||||||
object = { email: value };
|
object = {email: value};
|
||||||
} else {
|
} else {
|
||||||
object = { user: value };
|
object = {user: value};
|
||||||
}
|
}
|
||||||
fetch('https://api.account.skynet.ie/ldap/recover/password', {
|
fetch('https://api.account.skynet.ie/ldap/recover/password', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(object),
|
body: JSON.stringify(object),
|
||||||
mode: "cors"
|
mode: "cors"
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(res.status === 200){
|
if (res.status === 200) {
|
||||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
|
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>";
|
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
|
||||||
} else {
|
} else {
|
||||||
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(() => {
|
}).catch(() => {
|
||||||
document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>";
|
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 field = document.getElementById('options').value;
|
||||||
const inputEl = document.getElementById('value');
|
const inputEl = document.getElementById('value');
|
||||||
if(field === "email"){
|
if (field === "email") {
|
||||||
inputEl.type = 'email';
|
inputEl.type = 'email';
|
||||||
} else {
|
} else {
|
||||||
inputEl.type = 'text';
|
inputEl.type = 'text';
|
||||||
|
|
Loading…
Reference in a new issue