mirror of
				https://github.com/xfarrow/blink
				synced 2025-06-27 09:03:02 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			110 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			110 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <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>
 | |
| 
 | |
|     <div class="alert alert-success" role="alert" id="successAlert" style="display: none;">
 | |
|     </div>
 | |
| 
 | |
|     <div class="alert alert-danger" role="alert" id="errorAlert" style="display: none;">
 | |
|     </div>
 | |
| 
 | |
|     <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>
 | |
|                         <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
 | |
|                             </div>
 | |
|                         </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>
 | |
|                     </div>
 | |
|                 </div>
 | |
|             </div>
 | |
|         </div>
 | |
|     </div>
 | |
| 
 | |
|     <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>
 | |
| 
 | |
| </body>
 | |
| 
 | |
| </html> |