blink/frontend/vanilla/html/forgot-password.html

110 lines
4.2 KiB
HTML
Raw Normal View History

2024-03-23 19:20:17 +01:00
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
</script>
</head>
<body>
2024-03-26 09:35:44 +01:00
<div class="alert alert-success" role="alert" id="successAlert" style="display: none;">
2024-03-23 19:20:17 +01:00
</div>
2024-03-26 09:35:44 +01:00
<div class="alert alert-danger" role="alert" id="errorAlert" style="display: none;">
2024-03-23 19:20:17 +01:00
</div>
2024-03-26 09:35:44 +01:00
2024-03-23 19:20:17 +01:00
<div class="container d-flex flex-column">
<div class="row align-items-center justify-content-center
min-vh-100 g-0">
<div class="col-12 col-md-8 col-lg-4 border-top border-3 border-primary">
<div class="card shadow-sm">
<div class="card-body">
<div class="mb-4">
<h5>Forgot Password?</h5>
<p class="mb-2">Enter your registered email to reset the password
</p>
</div>
2024-03-26 09:35:44 +01:00
<div class="mb-3">
<input type="email" id="email" class="form-control" name="email"
placeholder="Enter Your Email" onblur="emailFieldLosesFocus();">
<div class="invalid-feedback">
Please enter an email address
2024-03-23 19:20:17 +01:00
</div>
2024-03-26 09:35:44 +01:00
</div>
<div class="mb-3 d-grid">
<button type="button" class="btn btn-primary" onclick="proceed();">
Continue
</button>
</div>
<span>Don't have an account? <a href="login.html">sign in</a></span>
2024-03-23 19:20:17 +01:00
</div>
</div>
</div>
</div>
</div>
2024-03-26 09:35:44 +01:00
<script src="../js/constants.js"></script>
<script src="../js/utils.js"></script>
<script>
async function proceed() {
if (!validateFields()) {
return;
}
const email = document.getElementById("email").value;
const response = await fetch(`${API_URL}/resetpassword/request`, {
method: "POST",
body: JSON.stringify({
email
}),
headers: createHeaders(null)
});
if(response.ok){
showSuccessAlert('An email has been sent to reset your password');
}
else{
showErrorAlert('Something went wrong. Try again later')
}
}
/*
* This function gets called when the e-mail field loses focus. This is
* done to inform the user whether the entered e-mail is in a valid format
*/
function emailFieldLosesFocus() {
const emailField = document.getElementById("email");
if (!emailField.value || !validateEmail(emailField.value)) {
emailField.classList.add("is-invalid");
} else {
emailField.classList.remove("is-invalid");
}
}
function validateFields() {
const emailField = document.getElementById("email");
var isFormValid = true;
if (!emailField.value || !validateEmail(emailField.value)) {
emailField.classList.add("is-invalid");
isFormValid = false;
}
return isFormValid;
}
function showSuccessAlert(message) {
const successAlert = document.getElementById('successAlert');
successAlert.innerHTML = message;
successAlert.style.display = 'block';
}
function showErrorAlert(message) {
const errorAlert = document.getElementById('errorAlert');
errorAlert.innerHTML = message;
errorAlert.style.display = 'block';
}
</script>
2024-03-23 19:20:17 +01:00
</body>
</html>