Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-06 11:50:04 +08:00
commit 4895c4c417
2 changed files with 21 additions and 13 deletions

View File

@ -51,7 +51,7 @@ button {
background-color: #007bff;
color: #fff;
border: none;
border-radius: 3px;
border-radius: 5px;
cursor: pointer;
}
@ -59,7 +59,6 @@ button:hover {
background-color: #0056b3;
}
/* Mobile */
@media screen and (max-width: 767px) {
.container {
@ -102,31 +101,40 @@ button:hover {
</head>
<body>
<div class="container">
<h2>Reset Password</h2>
<form id="resetForm">
<div class="form-group">
<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 class="form-group">
<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>
<button type="button" onclick="resetPassword()">Reset Password</button>
</form>
</div>
<script>
function resetPassword() {
const new_password = document.getElementById("new_password").value;
const confirm_password = document.getElementById("confirm_password").value;
if (!/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/.test(new_password)) {
alert("The password must be at least 8 characters in length, and contain at least 1 number, 1 lowercase letter and 1 uppercase letter.");
return;
}
if (new_password !== confirm_password) {
alert("Passwords do not match");
return;
}
sha256ToBase64(new_password).then((hash) => {
const data = {
new_password: hash,
@ -143,26 +151,26 @@ function resetPassword() {
.then(response => response.json())
.then(data => {
if (data.code == 200 ) {
alert(data.msg);
alert("reset password success");
window.location.href = "{{.HomePage}}";
{{/* setTimeout(function() {
window.location.href = "{{.HomePage}}";
}, 1000); */}}
} else {
alert(data.msg);
}
})
.catch(error => {
console.error('Error:', error);
// 在这里处理其他错误情况
});
});
}
function sha256ToBase64(message) {
const msgBuffer = new TextEncoder().encode(message);
return crypto.subtle.digest('SHA-256', msgBuffer).then((hashBuffer) => {
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashBase64 = btoa(hashArray.reduce((str, byte) => str + String.fromCharCode(byte), ''));
return hashBase64;
});
}

View File

@ -41,10 +41,10 @@ func (l *UserRegisterLogic) UserRegister(req *types.RequestUserRegister, userinf
return resp.SetStatus(basic.CodeOAuthEmailErr)
}
_, err := l.svcCtx.AllModels.FsUser.FindUserByEmail(l.ctx, req.Email)
if err == nil {
return resp.SetStatus(basic.CodeEmailExistsErr)
}
// _, err := l.svcCtx.AllModels.FsUser.FindUserByEmail(l.ctx, req.Email)
// if err == nil {
// return resp.SetStatus(basic.CodeEmailExistsErr)
// }
if !TimeLimit.Is(req.Email) {
return resp.SetStatus(basic.CodeEmailTimeShortErr)