Skip to content

Instantly share code, notes, and snippets.

@poojarsn
Created January 15, 2023 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poojarsn/cf6f79f33e0e2e4643bf3bb5ce42ba58 to your computer and use it in GitHub Desktop.
Save poojarsn/cf6f79f33e0e2e4643bf3bb5ce42ba58 to your computer and use it in GitHub Desktop.
Sitecore Azure AD B2C User.Identity.IsAuthenticated is false Set AuthenticationManager
/*
Reference
https://blog.baslijten.com/federated-authentication-in-sitecore-error-unsuccessful-login-with-external-provider/
*/
public void SignIn(string returnUrl)
{
// The param returnUrl is configured in Azure B2C Identity Provider.
// The redirect URL is to redirect to externallogincallback method of Sitecore Owin and then load returnUrl Sign-in
var properties = new AuthenticationProperties() { RedirectUri = "https://abc/identity/externallogincallback?ReturnUrl=/sign-in" };
//retain returnUrl to later redirect user to the page they first started
if(!string.IsNullOrWhiteSpace(returnUrl))
properties.Dictionary["returnUrl"] = returnUrl;
System.Web.HttpContext.Current.GetOwinContext().Authentication.Challenge(properties,
new string[] { "AzureB2C", "SignUpSignInPolicyKey" });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment