This commit is contained in:
eson 2023-09-05 16:51:32 +08:00
parent ff8d62399f
commit 1e837a6a4b
2 changed files with 5 additions and 9 deletions

View File

@ -147,15 +147,11 @@ function resetPassword() {
})
.then(response => {
if (response.ok && response.data.code == 200) {
console.log('Password reset successful');
// 在这里执行其他成功处理逻辑
// 显示成功消息或进行其他操作
document.getElementById('successMessage').innerText = response.data;
if (response.ok ) {
console.log(response.data);
document.getElementById('successMessage').innerText = response.data.msg;
} else {
console.error('Password reset failed');
// 在这里执行其他失败处理逻辑
// 显示失败消息或进行其他操作
document.getElementById('errorMessage').innerText = 'Password reset failed. Please try again.';
}

View File

@ -66,11 +66,11 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
return fmt.Errorf("password had been reset")
}
if *user.PasswordHash == rt.NewPassword {
if *user.PasswordHash == req.NewPassword {
return fmt.Errorf("the password is the same as the old one. It needs to be changed")
}
return tx.Where("id = ?", rt.UserId).Update("PasswordHash", rt.NewPassword).Error
return tx.Where("id = ?", rt.UserId).Update("PasswordHash", req.NewPassword).Error
})
if err != nil {