Trying to override CreateAsync function with ClaimsIdentityFactory

A few days ago I found a very good tutorial on MVC, Identity and OWIN by Ben Foster. Tutorial here

I just finished a tutorial and I found a problem trying to override the CreateAsync function. Visual Studio does not allow this.

This is the code:

public class AppUserClaimsIdentityFactory : ClaimsIdentityFactory<AppUser>
{
    public override async Task<ClaimsIdentity> CreateAsync(
        UserManager<AppUser> manager, 
        AppUser user, 
        string authenticationType)
    {
        var identity = await base.CreateAsync(manager, user, authenticationType);
        identity.AddClaim(new Claim(ClaimTypes.Country, user.Country));

        return identity;
    }
}

      

Does anyone know how I can solve this problem?

Decision

Thanks to @ETorre, the latest code!

public class AppUserClaimsIdentityFactory : ClaimsIdentityFactory<AppUser, string>
{
    public async override Task<ClaimsIdentity> CreateAsync(UserManager<AppUser, string> manager, 
            AppUser user, string authenticationType)
    {
        var identity = await base.CreateAsync(manager, user, authenticationType);
        identity.AddClaim(new Claim(ClaimTypes.Country, user.Country));

        return identity;
    }
}

      

+3


source to share


1 answer


Can you try to see the version? files on git use Microsoft.AspNet.Identity.Core.dll version 1 and now it is vervion 2. Try to internal check ClaimsIdentityFactory



+3


source







All Articles