fix
This commit is contained in:
parent
9547dcc891
commit
f3d9852f98
|
@ -56,15 +56,21 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
|
|||
|
||||
err = l.svcCtx.AllModels.FsUser.Transaction(l.ctx, func(tx *gorm.DB) error {
|
||||
user := &gmodel.FsUser{}
|
||||
err := tx.Model(user).Where("id = ?", rt.UserId).Take(user).Error
|
||||
err := tx.Where("id = ?", rt.UserId).Take(user).Error
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if *user.PasswordHash != rt.OldPassword {
|
||||
return fmt.Errorf("password had been reset")
|
||||
}
|
||||
return tx.Update("PasswordHash", rt.NewPassword).Error
|
||||
|
||||
if *user.PasswordHash == rt.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
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user