I am currently trying to expose a field from an authenticated user, but I'm having a bit of difficulty trying to add a new claim to the authenticated user.
In MVC5 I would do something similar to the following:
public class ApplicationUser : IdentityUser
{
public string FullName { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
userIdentity.AddClaim(new Claim("FullName", FullName));
return userIdentity;
}
}
When I attempt to do this in MVC6 however I run into problems with objects and methods missing. CreateIdentityAsync() and DefaultAuthenticationTypes both appear to be missing or so says visual studio and when I dig into the Identity source I can see that CreateIdentityAsync is no longer there, however I can't seem to find anything about DefaultAuthenticationTypes.
Right now at this point I think this is a nice to have, but its been driving me nuts for the past few days and would be nice to understand whats wrong or how this has changed.