From 2d831e44ab6891ec3de149584c81e336c4e96234 Mon Sep 17 00:00:00 2001 From: Judah Himango CW Date: Mon, 8 Jul 2019 17:04:17 -0500 Subject: [PATCH] UserStore creates a new TIdentityRole, rather than the basic IdentityRole. --- RavenDB.Identity/IdentityRole.cs | 11 +++++++---- RavenDB.Identity/RavenDB.Identity.csproj | 4 ++-- RavenDB.Identity/ServiceCollectionExtensions.cs | 2 +- RavenDB.Identity/UserStore.cs | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/RavenDB.Identity/IdentityRole.cs b/RavenDB.Identity/IdentityRole.cs index 056f0d2..909e655 100644 --- a/RavenDB.Identity/IdentityRole.cs +++ b/RavenDB.Identity/IdentityRole.cs @@ -9,13 +9,17 @@ namespace Raven.Identity /// public class IdentityRole : IdentityRole { + /// + /// Creates a new IdentityRole. + /// + public IdentityRole() + { + } + /// /// Initializes a new instance of . /// /// The role name. - /// - /// The Id property is initialized to from a new GUID string value. - /// public IdentityRole(string roleName) { Name = roleName; @@ -57,7 +61,6 @@ namespace Raven.Identity /// /// Gets or sets the primary key for this role. - /// Format: IdentityRoles/{roleName} /// public virtual string Id { get; set; } diff --git a/RavenDB.Identity/RavenDB.Identity.csproj b/RavenDB.Identity/RavenDB.Identity.csproj index b5e1200..c62c194 100644 --- a/RavenDB.Identity/RavenDB.Identity.csproj +++ b/RavenDB.Identity/RavenDB.Identity.csproj @@ -19,10 +19,10 @@ false false false - 6.0.6 + 6.1 False Raven.Identity - Fixed role.Name and user.Roles case sensitivity, which had been causing authorization issues. + Custom IdentityRole types are stored using their type name in the ID. UserStore can now handle custom IdentityRole types. LICENSE.md diff --git a/RavenDB.Identity/ServiceCollectionExtensions.cs b/RavenDB.Identity/ServiceCollectionExtensions.cs index fb682f7..fe6f763 100644 --- a/RavenDB.Identity/ServiceCollectionExtensions.cs +++ b/RavenDB.Identity/ServiceCollectionExtensions.cs @@ -35,7 +35,7 @@ namespace Raven.Identity /// The identity builder. public static IdentityBuilder AddRavenDbIdentity(this IServiceCollection services, Action setupAction = null) where TUser : IdentityUser - where TRole : IdentityRole + where TRole : IdentityRole, new() { // Add the AspNet identity system to work with our RavenDB identity objects. IdentityBuilder identityBuilder; diff --git a/RavenDB.Identity/UserStore.cs b/RavenDB.Identity/UserStore.cs index c51e8a3..26afb11 100644 --- a/RavenDB.Identity/UserStore.cs +++ b/RavenDB.Identity/UserStore.cs @@ -33,7 +33,7 @@ namespace Raven.Identity IUserTwoFactorRecoveryCodeStore, IQueryableUserStore where TUser : IdentityUser - where TRole : IdentityRole + where TRole : IdentityRole, new() { private bool _disposed; private readonly Func getSessionFunc; @@ -401,7 +401,8 @@ namespace Raven.Identity if (existingRoleOrNull == null) { ThrowIfDisposedOrCancelled(cancellationToken); - existingRoleOrNull = new IdentityRole(roleNameLowered); + existingRoleOrNull = new TRole(); + existingRoleOrNull.Name = roleNameLowered; await this.DbSession.StoreAsync(existingRoleOrNull, roleId, cancellationToken); }