Setting up the reset password page

This commit is contained in:
2024-08-21 12:27:09 +02:00
parent 2a5841d649
commit 333499f76e
3 changed files with 103 additions and 7 deletions

View File

@ -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)
}
});
}