Created
July 20, 2016 20:53
-
-
Save shawnweisfeld/597a01d3860195c2d0853fee34b41f22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SignIn(string authType) | |
{ | |
// Send an OpenID Connect sign-in request. | |
if (!Request.IsAuthenticated) | |
{ | |
string callbackUrl = Url.Action("SignInCallback", "Account", routeValues: new { authType = authType }, protocol: Request.Url.Scheme); | |
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = callbackUrl }, | |
authType); | |
} | |
} | |
public ActionResult SignInCallback(string authType) | |
{ | |
//NOTE: I am throwing the value into session state | |
//depending on your application you will probably want to store this in something more durable (i.e. Redis Cache) | |
Session["AuthType"] = authType; | |
return RedirectToAction("Index", "Home"); | |
} | |
public void SignOut() | |
{ | |
string callbackUrl = Url.Action("SignOutCallback", "Account", routeValues: null, protocol: Request.Url.Scheme); | |
HttpContext.GetOwinContext().Authentication.SignOut( | |
new AuthenticationProperties { RedirectUri = callbackUrl }, | |
Session["AuthType"].ToString(), CookieAuthenticationDefaults.AuthenticationType); | |
} | |
public ActionResult SignOutCallback() | |
{ | |
return RedirectToAction("Index", "Home"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment