Я переношу версию .NET 4.6 в .NET Core RC2 и задаюсь вопросом, как это сделать в .NET Core RC2.Претензии к signin в .NET Core RC2
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);
userIdentity.AddClaim(new Claim("FullName", string.Format("{0} {1}", this.Firstname, this.Lastname)));
userIdentity.AddClaim(new Claim("Organization", this.Organization.Name));
userIdentity.AddClaim(new Claim("Role", manager.GetRoles(this.Id).FirstOrDefault()));
userIdentity.AddClaim(new Claim("ProfileImage", this.ProfileImageUrl));
// Add custom user claims here
return userIdentity;
}
, а затем метод расширения для удостоверения личности.
public static class IdentityExtensions
{
public static string FullName(this IIdentity identity)
{
var claim = ((ClaimsIdentity)identity).FindFirst("FullName");
// Test for null to avoid issues during local testing
return (claim != null) ? claim.Value : string.Empty;
}
public static string Organization(this IIdentity identity)
{
var claim = ((ClaimsIdentity)identity).FindFirst("Organization");
// Test for null to avoid issues during local testing
return (claim != null) ? claim.Value : string.Empty;
}
public static string Role(this IIdentity identity)
{
var claim = ((ClaimsIdentity)identity).FindFirst("Role");
// Test for null to avoid issues during local testing
return (claim != null) ? claim.Value : string.Empty;
}
public static string ProfileImage(this IIdentity identity)
{
var claim = ((ClaimsIdentity)identity).FindFirst("ProfileImage");
// Test for null to avoid issues during local testing
return (claim != null) ? claim.Value : string.Empty;
}
}
Который дает мне результат использования User.Identity.ProfileImg();
и т.д ..
я надеюсь, что это получает в ответ, потому что я хотел бы знать сам. – conterio
Я получаю ответ о том, как я решил его, когда вернусь к своему компьютеру. @JeremyConterio – Rovdjuret
, что было бы замечательно – conterio