diff --git a/fs_template/reset_confirm.tpl b/fs_template/reset_confirm.tpl index 8a5d848d..c63a5ae8 100644 --- a/fs_template/reset_confirm.tpl +++ b/fs_template/reset_confirm.tpl @@ -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.'; } diff --git a/server/auth/internal/logic/userresetpasswordlogic.go b/server/auth/internal/logic/userresetpasswordlogic.go index e1e90c5f..5d38b4ce 100644 --- a/server/auth/internal/logic/userresetpasswordlogic.go +++ b/server/auth/internal/logic/userresetpasswordlogic.go @@ -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 {