/// <summary> /// Removes the custom account provider value from cookie. /// </summary> /// <param name="accountProviderId">The account provider identifier.</param> internal static void RemoveCustomAccountProviderValueFromCookie(Identifier accountProviderId) { if (HttpContext.Current != null) { CookieManager.SetCustomAccountProviderValueInCookie(null, accountProviderId); } }
/// <param name="sessionSecret">The session secret.</param> /// <param name="accountProviderId">The account provider identifier.</param> internal static void SetCustomAccountProviderValueInCookie(string value, Identifier accountProviderId) { if (HttpContext.Current != null) { HttpResponse response = HttpContext.Current.Response; HttpRequest request = HttpContext.Current.Request; HttpCookie cookie; if (request.Cookies.AllKeys.Contains(CustomAccountProviderCookieName)) { cookie = request.Cookies[CustomAccountProviderCookieName]; cookie.HttpOnly = true; cookie.Secure = true; } else { cookie = new HttpCookie(CustomAccountProviderCookieName) { HttpOnly = true, Secure = true }; } CookieManager.SetCustomAccountProviderValueInCookie(cookie, value, accountProviderId); response.Cookies.Add(cookie); } }
public ActionResult SignInPost(CustomAccountProviderSignInViewModel model) { Debug.Assert(model != null); if (!ModelState.IsValid) { return(CustomView(model)); } var returnUrl = new Uri(model.ReturnUrl); if (!CustomAccountProviderManager.ValidateReturnUrl(returnUrl)) { return(new HttpUnauthorizedResult()); } // Do validation // If the user is in the process of linking his account to another account there is the account provider can be retrieved with GetLinkAccountAccountProvider()) var accountProvider = (GetAccountProvider() as CustomAccountProvider) ?? GetLinkAccountAccountProvider() as CustomAccountProvider; if (accountProvider == null) { return(new HttpUnauthorizedResult()); } CookieManager.SetCustomAccountProviderValueInCookie("124578895613", new Framework.Cryptography.Identifier(accountProvider.AccountProviderId)); return(new RedirectResult(returnUrl.AbsoluteUri)); }