From 95ea3159acf815bb1004676f7b75c74021e3cea5 Mon Sep 17 00:00:00 2001 From: Josh Close Date: Sun, 7 Jul 2019 22:52:23 -0500 Subject: [PATCH] Changed UserStore.AddToRoleAsync to use TRole instead of IdentityRole. --- RavenDB.Identity/ServiceCollectionExtensions.cs | 2 +- RavenDB.Identity/UserStore.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/RavenDB.Identity/ServiceCollectionExtensions.cs b/RavenDB.Identity/ServiceCollectionExtensions.cs index caf6b45..fb682f7 100644 --- a/RavenDB.Identity/ServiceCollectionExtensions.cs +++ b/RavenDB.Identity/ServiceCollectionExtensions.cs @@ -50,7 +50,7 @@ namespace Raven.Identity .AddDefaultTokenProviders(); } - services.AddScoped, UserStore>(); + services.AddScoped, UserStore>(); services.AddScoped, RoleStore>(); return identityBuilder; diff --git a/RavenDB.Identity/UserStore.cs b/RavenDB.Identity/UserStore.cs index 9ac7e4c..c51e8a3 100644 --- a/RavenDB.Identity/UserStore.cs +++ b/RavenDB.Identity/UserStore.cs @@ -16,7 +16,8 @@ namespace Raven.Identity /// UserStore for entities in a RavenDB database. /// /// - public class UserStore : + /// + public class UserStore : IUserStore, IUserLoginStore, IUserClaimStore, @@ -32,6 +33,7 @@ namespace Raven.Identity IUserTwoFactorRecoveryCodeStore, IQueryableUserStore where TUser : IdentityUser + where TRole : IdentityRole { private bool _disposed; private readonly Func getSessionFunc; @@ -390,7 +392,7 @@ namespace Raven.Identity ThrowIfNullDisposedCancelled(user, cancellationToken); // See if we have an IdentityRole with that name. - var identityUserCollection = DbSession.Advanced.DocumentStore.Conventions.GetCollectionName(typeof(IdentityRole)); + var identityUserCollection = DbSession.Advanced.DocumentStore.Conventions.GetCollectionName(typeof(TRole)); var prefix = DbSession.Advanced.DocumentStore.Conventions.TransformTypeCollectionNameToDocumentIdPrefix(identityUserCollection); var identityPartSeperator = DbSession.Advanced.DocumentStore.Conventions.IdentityPartsSeparator; var roleNameLowered = roleName.ToLowerInvariant(); @@ -423,7 +425,7 @@ namespace Raven.Identity user.GetRolesList().RemoveAll(r => string.Equals(r, roleName, StringComparison.InvariantCultureIgnoreCase)); - var roleId = RoleStore.GetRavenIdFromRoleName(roleName, DbSession.Advanced.DocumentStore); + var roleId = RoleStore.GetRavenIdFromRoleName(roleName, DbSession.Advanced.DocumentStore); var roleOrNull = await DbSession.LoadAsync(roleId, cancellationToken); if (roleOrNull != null) {