Reputation: 41
I have created a MyClaimsIdentity
class that inherits from ClaimsIdentity
. When I run my app the CreateAsync
method is never called and I never see the custom claims that I added.
There are no compile errors and if I add the default constructor I can see that this class is constructed however no breakpoints are hit within the CreateAsync
method.
public class MyClaimsFactory : ClaimsIdentityFactory<User, string>
{
public override async Task<ClaimsIdentity> CreateAsync(UserManager<User, string> manager, User user, string authenticationType)
{
var identity = await base.CreateAsync(manager, user, authenticationType);
if (!String.IsNullOrWhiteSpace(user.FirstName))
{
identity.AddClaim(new Claim("given_name", user.FirstName));
}
return identity;
}
Upvotes: 2
Views: 870
Reputation: 41
Setting this as the answer, thanks.
Are you using IdentityServer by chance? If so this may help you... github.com/IdentityServer/IdentityServer3/issues/1204 – Jeremy Aug 3 at 16:13
Upvotes: 1