public JsonResult UpdatePassword(UserUpdatePasswordVo userUpdate) { userUpdate.OldPassword = AuthManager.EncryptPassword(userUpdate.OldPassword); userUpdate.NewPassword = AuthManager.EncryptPassword(userUpdate.NewPassword); UserService.UpdatePassword(userUpdate, AuthManager.ReadUserInfo()); return(Json(this.Ok(true))); }
/// <summary> /// 修改密码 /// </summary> public void UpdatePassword(UserUpdatePasswordVo userUpdatePassword, AuthUserModel authUserModel) { if (authUserModel == null) { throw new BusinessException("未获取到当前登录用户信息"); } if (!userUpdatePassword.BusinessId.HasValue) { throw new BusinessException("用户Id不允许为空"); } if (string.IsNullOrEmpty(userUpdatePassword.OldPassword)) { throw new BusinessException("请输入原始密码"); } if (userUpdatePassword.OldPassword.Length > 50) { throw new BusinessException("原始密码最大长度为50"); } if (string.IsNullOrEmpty(userUpdatePassword.NewPassword)) { throw new BusinessException("请输入新密码"); } if (userUpdatePassword.NewPassword.Length > 50) { throw new BusinessException("新密码最大长度为50"); } var temp = UserDA.GetById(userUpdatePassword.BusinessId.Value); if (!userUpdatePassword.OldPassword.Equals(temp.LoginPassword)) { throw new BusinessException("对不起,您输入的密码错误"); } UserDA.UpadtePassword(new UserEntity() { Id = userUpdatePassword.BusinessId.Value, LoginPassword = userUpdatePassword.NewPassword, Updater = authUserModel.UserSysNo, UpdateTime = DateTime.Now }); }