public ActionResult HandleLogin(SessionIdentity account, bool persistCookie, Action onSessionInit, string url) { GlobalState.InitializeSession(account); onSessionInit(); FormsAuthentication.SetAuthCookie(account.CookieString, persistCookie); if (string.IsNullOrEmpty(url)) { url = FormsAuthentication.GetRedirectUrl(account.CookieString, persistCookie); // this one crashes dev fabric //FormsAuthentication.RedirectFromLoginPage(username, persistCookie); } // we might need to unencode while (url.StartsWith("%")) { url = Uri.UnescapeDataString(url); } // this is MVC app, so no default.aspx any more if (url.EndsWith("/default.aspx")) { url = null; } if (string.IsNullOrEmpty(url)) { // web site might be located in the nested folder url = HttpContext.Current.Request.ApplicationPath; } return new RedirectResult(url, false); }
public ActionResult HandleLogin(SessionIdentity account, bool persistCookie, Action onSessionInit, string url) { GlobalState.InitializeSession(account); onSessionInit(); FormsAuthentication.SetAuthCookie(account.CookieString, persistCookie); if (string.IsNullOrEmpty(url)) { url = FormsAuthentication.GetRedirectUrl(account.CookieString, persistCookie); // this one crashes dev fabric //FormsAuthentication.RedirectFromLoginPage(username, persistCookie); } // we might need to unencode while (url.StartsWith("%")) { url = Uri.UnescapeDataString(url); } // this is MVC app, so no default.aspx any more if (url.EndsWith("/default.aspx")) { url = null; } if (string.IsNullOrEmpty(url)) { // web site might be located in the nested folder url = HttpContext.Current.Request.ApplicationPath; } return(new RedirectResult(url, false)); }
/// <summary> /// Single point of entry to initialize the session /// </summary> /// <param name="accountSession">The account session.</param> public static void InitializeSession(SessionIdentity accountSession) { var session = HttpContext.Current.Session; session[AccountSessionKey] = accountSession; }
public AuthenticationResult(SessionIdentity identity) { Identity = identity; IsSuccess = true; }
/// <summary> /// Initializes a new instance of the <see cref="AuthPrincipal"/> class. /// </summary> /// <param name="account">The account.</param> public AuthPrincipal(SessionIdentity account) { Identity = account; _identity = new GenericIdentity(account.SessionDisplay); }
public ActionResult HandleLogin(SessionIdentity account, bool persistCookie, string redirect = null) { return(HandleLogin(account, persistCookie, () => { HttpContext.Current.Session["LoginAge"] = DateTime.UtcNow; }, redirect)); }
public ActionResult HandleLogin(SessionIdentity account, bool persistCookie, string redirect = null) { return HandleLogin(account, persistCookie, () => { HttpContext.Current.Session["LoginAge"] = DateTime.UtcNow; }, redirect); }