Пример #1
0
        public async Task <AjaxResponse> UpdateUserPass(UserPassInput model)
        {
            if (model.NewPass != model.CheckPass)
            {
                throw new UserFriendlyException("密码修改", "您修改的两次密码输入不一致");
            }
            long id = Convert.ToInt64(model.ID);
            //获取需要更新的数据
            UserInfo data = _userInfoRepository.Get(id);
            //验证密码
            var verificationResult = _userInfoManager.VerifyPassword(data.Password, model.OldPass);

            if (!verificationResult)
            {
                throw new UserFriendlyException("密码修改", "您输入的旧密码有误请重新输入");
            }
            //更新原密码
            data.Password = new PasswordHasher <UserInfo>().HashPassword(data, model.NewPass);
            //提交修改
            await _userInfoManager.UpdateAsync(data);

            return(new AjaxResponse {
                Success = true
            });
        }
Пример #2
0
 /// <summary>
 /// 个人设置-修改账户密码
 /// </summary>
 /// <returns></returns>
 public virtual async Task <AjaxResponse> UpdateUserPassExtension(UserPassInput model)
 {
     /*扩展执行修改密码前的业务*/
     return(await _userInfoAppService.UpdateUserPass(model));
 }