Created
November 12, 2022 08:54
-
-
Save poojarsn/a63c4cae5bdeefa34e7c201d6416956e 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
//Azure AD B2C Owin Context is null , once the token is acquired by authorization code flow | |
//Set Authentication Manager profile | |
var authenticated = HttpContext.GetOwinContext().Authentication.AuthenticateAsync("ExternalCookie"); | |
// Send Access Token bearer to api to get logged user details | |
var loggedInUser = AuthenticationManager.BuildVirtualUser(string.Format(@"{0}\{1}", "external", "User-ID"), true); | |
loggedInUser.RuntimeSettings.AddedRoles.Add(authenticated.Result.Identity.Claims.First().Value); | |
loggedInUser.Profile.FullName = string.Format("{0} {1}", authenticated.Result.Identity.Name, authenticated.Result.Identity.Claims.Last().Value); | |
loggedInUser.Profile.Save(); | |
AuthenticationManager.Login(loggedInUser); | |
userObject.IsAuthenticated = User.Identity.IsAuthenticated; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment