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); }
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); }
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); }
public ActionResult CambiarPassword(string tokenNumber, string passwordChange) { string emailDesencriptado = string.Empty; ManagerCookie cookie = new ManagerCookie(); ClientCookie coookieSession = cookie.ObtenerCookie(HttpContext.Request.Cookies["userAuth"]); string emailEncriptado = string.IsNullOrEmpty(coookieSession.userName) ? string.Empty : coookieSession.userName.ToString(); if (!emailEncriptado.IsEmpty()) { Seguridad seguridad = new Seguridad(); emailDesencriptado = seguridad.desencriptar(emailEncriptado); } long respuesta = new BRecuperarPassword().CambiarPassword(emailDesencriptado, tokenNumber, passwordChange); return(Json(respuesta)); }
// string urlBase = "https://www.grupos.co/"; public ActionResult vuelosyOtros() { try { ManagerCookie cookie = new ManagerCookie(); ClientCookie coookieSession = cookie.ObtenerCookie(HttpContext.Request.Cookies["userAuth"]); ViewData["userName"] = string.IsNullOrEmpty(coookieSession.userName) ? string.Empty : coookieSession.userName.ToString(); if (coookieSession != null) { return(View()); } return(Content("<script language='javascript' type='text/javascript'>alert('Acceso no autorizado.');window.location.href = '" + urlBase + "';</script>")); } catch (GettingException ex) { StackTrace st = new StackTrace(ex, true); StackFrame frame = st.GetFrame(0); throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString())); } }