Setting up the reset password page
This commit is contained in:
@ -80,3 +80,44 @@ export function forgot(api) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function reset(api) {
|
||||
let form = document.getElementById("reset-form");
|
||||
|
||||
if (form.checkValidity() === false) {
|
||||
// this.event.preventDefault();
|
||||
// this.event.stopPropagation();
|
||||
form.classList.add("was-validated");
|
||||
return;
|
||||
}
|
||||
form.classList.add("was-validated");
|
||||
|
||||
if (document.getElementById("password").value !== document.getElementById("verify-password").value) {
|
||||
showError("reset-messages", "Passwords do not match.")
|
||||
return
|
||||
}
|
||||
|
||||
let payload = {
|
||||
email: document.getElementById("email").value,
|
||||
};
|
||||
|
||||
const requestOptions = {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
};
|
||||
|
||||
fetch(api + "/api/reset-password", requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
if (response.error === false) {
|
||||
showSuccess("reset-messages", "Password reset")
|
||||
} else {
|
||||
showError("reset-messages", response.message)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user