Fix file paths and add password reset functionality

This commit is contained in:
newtbot
2024-01-31 03:17:24 +08:00
parent 12597ad774
commit fea986a841
12 changed files with 169 additions and 39 deletions

View File

@@ -5,9 +5,12 @@
<section class="wrapper">
<div class="form">
<header>Reset Password</header>
<form action="auth/resetPassword" >
<input type="password" name="password" placeholder="password" required>
<input type="cpassword" name="cpassword" placeholder="cpassword" required>
<div class="card-header shadow actionMessage" style="display:none"></div>
<!-- <form action="auth/resetpassword/<%= token.token%>" method="post" onsubmit="formAJAX(this)"> -->
<form action="auth/resetpassword/<%= token%>" method="post" onsubmit="formAJAX(this)" evalAJAX="app.auth.logInRedirect();">
<input type="password" id="password" name="password" placeholder="Password" required />
<input type="password" id="confirmPassword" name="confirmPassword" placeholder="Confirm Password"
required />
<input type="submit" value="Reset Password" />
</form>
<br>
@@ -15,12 +18,29 @@
</div>
</section>
<table class="footer">
<tr>
<td>
<p>&copy; 2024 EcoSaver</p>
</td>
</tr>
</table>
</body>
<script>
//both password fields must match
var password = document.getElementById("password");
var confirm_password = document.getElementById("confirmPassword");
function validatePassword() {
var passwordValue = password.value;
// Strong password regex pattern
var strongPasswordPattern = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/;
if (passwordValue != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
} else if (!strongPasswordPattern.test(passwordValue)) {
confirm_password.setCustomValidity("Password must be at least 8 characters long and include at least one letter, one number, and one special character.");
} else {
confirm_password.setCustomValidity('');
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
</script>