Home > Net >  How can I convert Identity user to Claims Principal User?
How can I convert Identity user to Claims Principal User?

Time:09-03

I want use User.IsInRole() function in my api controller. I have Identity user ,how could I convert it to ClaimsPrincipal or use User.IsInRole() with Identity user ?!?!?!

CodePudding user response:

You can use SignInManager<TUser>.CreateUserPrincipalAsync(TUser) method.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinmanager-1.createuserprincipalasync?view=aspnetcore-6.0

  • Related