Exemplo n.º 1
0
        public override async Task <bool> DoLogin()
        {
            if (IsLogined || !this.CanLogin)
            {
                return(IsLogined);
            }

            var loginData = new NameValueCollection
            {
                { "action", "login" },
                { "log", this.Name },
                { "pwd", this.Password },
                { "rememberme", "forever" },
                { "wp-submit", "" },
                { "instance", "" },
                { "redirect_to", BookmarksUri.OriginalString },
            };

            try
            {
                var loginResult = await GetClient().UploadValuesTaskAsync(new Uri(this.MainUri + "login"), "POST", loginData).ConfigureAwait(false);

                LogoutNonce = Regex.Match(System.Text.Encoding.UTF8.GetString(loginResult), "logout\\/\\?_wpnonce=([a-z0-9]+)&", RegexOptions.Compiled).Groups[1].Value;
                var hasLoginCookie = ClientCookie.GetCookies(this.MainUri)
                                     .Cast <Cookie>()
                                     .Any(c => c.Name.StartsWith("wordpress_logged_in"));
                this.IsLogined = hasLoginCookie;
            }
            catch (System.Exception ex)
            {
                Log.Exception(ex, Strings.Login_Failed);
                this.IsLogined = false;
            }
            return(IsLogined);
        }
Exemplo n.º 2
0
        public override async Task <bool> DoLogin()
        {
            if (IsLogined || !this.CanLogin)
            {
                return(IsLogined);
            }

            var loginData = new NameValueCollection
            {
                { "submit", "login" },
                { "username", this.Name },
                { "password", this.Password },
                { "check", "1" }
            };

            try
            {
                await GetClient().UploadValuesTaskAsync(new Uri(this.MainUri + "action/authLogin"), "POST", loginData);

                this.PasswordHash = ClientCookie.GetCookies(this.MainUri)
                                    .Cast <Cookie>()
                                    .Single(c => c.Name == "hash")
                                    .Value;
                this.IsLogined = true;
            }
            catch (System.Exception ex)
            {
                Log.Exception(ex, Strings.Login_Failed);
                this.IsLogined = false;
            }
            return(IsLogined);
        }
Exemplo n.º 3
0
        public override async Task <bool> DoLogin()
        {
            if (IsLogined || !this.CanLogin)
            {
                return(IsLogined);
            }

            var loginData = new NameValueCollection
            {
                { "login", "submit" },
                { "login_name", this.Name },
                { "login_password", this.Password },
                { "image", "%D0%92%D1%85%D0%BE%D0%B4" }
            };

            try
            {
                await GetClient().UploadValuesTaskAsync(new Uri(MainUri, "index.php"), "POST", loginData);

                this.UserId = ClientCookie.GetCookies(this.MainUri)
                              .Cast <Cookie>()
                              .Single(c => c.Name == "dle_user_id")
                              .Value;
                this.IsLogined = true;
            }
            catch (System.Exception ex)
            {
                Log.Exception(ex, Strings.Login_Failed);
                this.IsLogined = false;
            }
            return(IsLogined);
        }