UserManager does not contain a definition for CreateIdentity

I am trying to port this code to ASP.NET V5:

public ClaimsIdentity GenerateUserIdentity(UserManager<User> manager, string authenticationType) { var userIdentity = manager.CreateIdentity(this, authenticationType); ... 

I get an error UserManager<User> does not contain a definition for CreateIdentity

Any ideas how to fix this?

+1
Nov 04 '15 at 6:20
source share
1 answer

To create a ClaimsPrincipal object from a TUser object, you can import IUserClaimsPrincipalFactory<TUser> into your own code and call CreateAsync :

 var principal = await factory.CreateAsync(user); 

Alternatively, you can also use the UserManager<TUser>.GetClaimsAsync - something that UserClaimsPrincipalFactory<TUser> uses behind the scenes - and create the ClaimsIdentity yourself:

 var identity = new ClaimsIdentity(await manager.GetClaimsAsync(user), authenticationType); 
+2
Nov 04 '15 at 20:21
source share



All Articles