コード例 #1
0
ファイル: UserService.cs プロジェクト: whilliy/HaozhuoCrm
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="vo"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static void ResetUserPassword(ResetUserPassword vo, String token)
        {
            RestClient rs      = new RestClient();
            var        request = new RestRequest(GlobalConfig.RESET_USER_PASSWORD);

            request.AddHeader(GlobalConfig.AUTHORIZATION, token);
            request.AddJsonBody(vo);
            IRestResponse response;

            try
            {
                response = rs.Execute(request, Method.PATCH);
            }
            catch (Exception ex)
            {
                throw new BusinessException(ex.Message);
            }
            if (response.StatusCode == 0)
            {
                throw new BusinessException("请检查网络");
            }
            if (response.StatusCode != HttpStatusCode.NoContent)
            {
                var res             = rs.Deserialize <CustomException>(response);
                var customException = res.Data;
                throw new BusinessException(customException.message);
            }
        }
コード例 #2
0
        public IHttpActionResult ResetPasssword(ResetUserPassword model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString()
            };

            if (string.IsNullOrWhiteSpace(model.Guid))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "必要参数缺失,请检查";
                return(Ok(response));
            }

            UserAccountModel content = usermanager.GetUser(model.Guid);

            content.UserPswd = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes("fujica"))).Replace("-", "");
            if (!usermanager.ModifyUser(content))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_FAIL;
                response.MessageContent = usermanager.LastErrorDescribe; //ApiBaseErrorCode.API_FAIL.ToString();
            }
            return(Ok(response));
        }
コード例 #3
0
        public UserRegistration ResetPassword(ResetUserPassword reset)
        {
            
            var result = this.userDbContext.Users.Where<UserRegistration>(user => user.Email == reset.Email).FirstOrDefault();
            if (result != null)
            {
                result.Password = reset.Password;
                this.userDbContext.Users.Update(result);
                var saveResult=this.userDbContext.SaveChanges();
                if (saveResult != 0)
                {
                    return result;
                }
            }
            return null;

        }
コード例 #4
0
 public ActionResult ResetPassword(ResetUserPassword user)
 {
     try
     {
         if (user.Password != user.ConfirmPassword)
         {
             return(this.BadRequest(new { Status = false, Message = "password match unsuccessfull" }));
         }
         var result = this.userManager.ResetPassword(user);
         if (result != null)
         {
             return(this.Ok(new { Status = true, Message = "Password reset Successfully", Data = result }));
         }
         return(this.NotFound(new { Status = false, Message = "Password reset UnSuccessfully" }));
     }
     catch (Exception e)
     {
         return(this.BadRequest(new { Status = false, Message = e.Message }));
     }
 }
コード例 #5
0
 public async Task <Response <UserDto> > ResetUserPasswordAsync(ResetUserPassword command)
 => await PutAsync <UserDto>($"api/users/{command.Username}/password/reset", command);
コード例 #6
0
 public UserRegistration ResetPassword(ResetUserPassword reset)
 {
     return(this.userRepo.ResetPassword(reset));
 }