/// <summary> /// 修改密码 /// </summary> /// <param name="modifyInfo">修改信息</param> /// <returns></returns> public Result ModifyPassword(ModifyUserPassword modifyInfo) { #region 参数判断 if (modifyInfo == null) { return(Result.FailedResult("密码修改信息为空")); } #endregion //获取用户 IQuery query = QueryFactory.Create <UserQuery>(u => u.SysNo == modifyInfo.SysNo); User nowUser = userRepository.Get(query); if (nowUser == null) { return(Result.FailedResult("用户不存在")); } //验证当前密码 if (modifyInfo.CheckOldPassword && nowUser.Pwd != User.PasswordEncryption(modifyInfo.NowPassword)) { return(Result.FailedResult("当前密码不正确")); } nowUser.ModifyPassword(modifyInfo.NewPassword);//设置新密码 nowUser.Save(); return(Result.SuccessResult("密码修改成功")); }
public ActionResult ModifyPassword(ModifyUserPassword model, string url) { try { _userService.ModifyPassword(model.UserAccount, model.Password, model.NewPassword); } catch (Exception ex) { ViewBag.message = ex.Message; return(View(model)); } return(Login(model.UserAccount, model.NewPassword, url)); }