I have created an app which is using Azure AD authentication. After user is authenticated, I want to get the user's unique Id and get the group information which I want to save in a session so then that group information can be fetched in any controller action.
One good place to do that would be right SignIn() method method but this code does not execute because of the cache and user can get to the default page.
So what would be the best possible solution to create the session prior to user start any activity on the application after user is authenticated?
In this page i should be able to check if user is authenticated, username and also get users unique id as follow:
var userName = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("name").Value;
var IsAuthenticated = HttpContext.User.Identity.IsAuthenticated;
var uniqueId = system.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;