fix
This commit is contained in:
parent
4d0081b19c
commit
5a9a23eb9c
|
@ -59,7 +59,6 @@ button:hover {
|
||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Mobile */
|
/* Mobile */
|
||||||
@media screen and (max-width: 767px) {
|
@media screen and (max-width: 767px) {
|
||||||
.container {
|
.container {
|
||||||
|
@ -102,31 +101,34 @@ button:hover {
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Reset Password</h2>
|
<h2>Reset Password</h2>
|
||||||
|
|
||||||
<form id="resetForm">
|
<form id="resetForm">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="new_password">New Password</label>
|
<label for="new_password">New Password</label>
|
||||||
<input id="new_password" type="password" placeholder="New password" required pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$">
|
<input id="new_password" type="password" placeholder="New password" required pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$" title="The password must be at least 8 characters in length, and contain at least 1 number, 1 lowercase letter and 1 uppercase letter."/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm_password">Confirm Password</label>
|
<label for="confirm_password">Confirm Password</label>
|
||||||
<input id="confirm_password" type="password" placeholder="Confirm password" required pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$">
|
<input id="confirm_password" type="password" placeholder="Confirm password" required pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$" title="The password must be at least 8 characters in length, and contain at least 1 number, 1 lowercase letter and 1 uppercase letter."/>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" onclick="resetPassword()">Reset Password</button>
|
<button type="button" onclick="resetPassword()">Reset Password</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
function resetPassword() {
|
function resetPassword() {
|
||||||
const new_password = document.getElementById("new_password").value;
|
const new_password = document.getElementById("new_password").value;
|
||||||
const confirm_password = document.getElementById("confirm_password").value;
|
const confirm_password = document.getElementById("confirm_password").value;
|
||||||
|
|
||||||
if (new_password !== confirm_password) {
|
if (new_password !== confirm_password) {
|
||||||
alert("Passwords do not match");
|
alert("Passwords do not match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sha256ToBase64(new_password).then((hash) => {
|
sha256ToBase64(new_password).then((hash) => {
|
||||||
const data = {
|
const data = {
|
||||||
new_password: hash,
|
new_password: hash,
|
||||||
|
@ -144,25 +146,25 @@ function resetPassword() {
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.code == 200 ) {
|
if (data.code == 200 ) {
|
||||||
alert(data.msg);
|
alert(data.msg);
|
||||||
window.location.href = "{{.HomePage}}";
|
{{/* window.location.href = "{{.HomePage}}"; */}}
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.href = "{{.HomePage}}";
|
||||||
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
alert(data.msg);
|
alert(data.msg);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
// 在这里处理其他错误情况
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function sha256ToBase64(message) {
|
function sha256ToBase64(message) {
|
||||||
const msgBuffer = new TextEncoder().encode(message);
|
const msgBuffer = new TextEncoder().encode(message);
|
||||||
|
|
||||||
return crypto.subtle.digest('SHA-256', msgBuffer).then((hashBuffer) => {
|
return crypto.subtle.digest('SHA-256', msgBuffer).then((hashBuffer) => {
|
||||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||||
const hashBase64 = btoa(hashArray.reduce((str, byte) => str + String.fromCharCode(byte), ''));
|
const hashBase64 = btoa(hashArray.reduce((str, byte) => str + String.fromCharCode(byte), ''));
|
||||||
|
|
||||||
return hashBase64;
|
return hashBase64;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user