Beispiel #1
0
        public Result ChangePwd([FromBody] ChangePwdDto dto) =>
        HandleRequest <Result> ((userID) => {
            var result = _Account.ChangePwd(dto);
            if (result.Exception is IdentityException)
            {
                result.Message = "密码错误";
            }

            return(result);
        });
Beispiel #2
0
        public async Task <IActionResult> ChangePasswordAsync([FromBody] ChangePwdDto changePwdDto)
        {
            var user = await _userManager.FindByNameAsync(changePwdDto.UserName);

            var oldPwd = EncryptHelper.DecryptWithAES(changePwdDto.CurrentPwd);
            var newPwd = EncryptHelper.DecryptWithAES(changePwdDto.NewPwd);
            var result = await _userManager.ChangePasswordAsync(user, oldPwd, newPwd);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors));
            }
            await _signInManager.SignOutAsync();

            return(Ok());
        }
Beispiel #3
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public bool ChangePwd(ChangePwdDto dto)
        {
            var entity = _dbContext.TbUser.FirstOrDefault(x => x.UserNo == dto.userNo && x.UserPassword == dto.oldPwd);

            if (entity != null)
            {
                entity.UserPassword = dto.newPwd;
                entity.UpdateTime   = DateTime.Now;
                entity.UpdateBy     = entity.UserId.ToString();
                using (_dbContext)
                {
                    _dbContext.TbUser.Update(entity);
                    return(_dbContext.SaveChanges() > 0 ? true : false);
                }
            }
            return(false);
        }
Beispiel #4
0
        public IActionResult ChangePwd(ChangePwdDto changePwdDto)
        {
            changePwdDto.Email = changePwdDto.Email.Trim();
            //第一步 是否发送过短消息 查询最后一次发送短消息实体对象,验证是否超时
            EmailValidateCodeLog entity = _userService.GetEmailLog(changePwdDto.Email);

            if (entity != null)
            {
                if (SMSHelper.CheckTime(entity.CreateTime) > 30 * 60)
                {
                    return(Ok(new ResponseBody()
                    {
                        ResponseCode = ResponseCodeEnum.Fail, ResponseMessage = "验证码已过期"
                    }));
                }
                if (entity.ValidateCode == changePwdDto.Code)
                {
                    //修改密码
                    var reuslt = _userService.ChangePwdByEmail(changePwdDto.Email, changePwdDto.NewPassword);
                    if (reuslt)
                    {
                        return(Ok(new ResponseBody()
                        {
                            ResponseCode = ResponseCodeEnum.Success, ResponseMessage = "修改密码成功"
                        }));
                    }
                    return(Ok(new ResponseBody()
                    {
                        ResponseCode = ResponseCodeEnum.Fail, ResponseMessage = "修改密码失败"
                    }));
                }
                else
                {
                    return(Ok(new ResponseBody()
                    {
                        ResponseCode = ResponseCodeEnum.Fail, ResponseMessage = "验证码错误"
                    }));
                }
            }
            return(Ok(new ResponseBody()
            {
                ResponseCode = ResponseCodeEnum.Fail, ResponseMessage = "请求失败,请重新获取验证码"
            }));
        }
Beispiel #5
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public Result ChangePwd(ChangePwdDto dto) =>
 _Repo.ChangePassword(GetEntity <User> (dto), dto.NewPasswordHash).ToResult();
Beispiel #6
0
        public async Task <IHttpActionResult> ChangeUserPassword(ChangePwdDto dto)
        {
            var result = await _userService.ChangeUserPassword(dto);

            return(Ok(result));
        }
Beispiel #7
0
        public IActionResult ChangePwd(ChangePwdDto dto)
        {
            var res = _userInfoService.ChangePwd(dto);

            return(Ok(res));
        }