diff --git a/RavenDB.Identity/RavenDB.Identity.csproj b/RavenDB.Identity/RavenDB.Identity.csproj index 5556bcd..1470ff2 100644 --- a/RavenDB.Identity/RavenDB.Identity.csproj +++ b/RavenDB.Identity/RavenDB.Identity.csproj @@ -18,7 +18,7 @@ false false false - 2.0.3 + 2.0.4 False diff --git a/RavenDB.Identity/ServiceCollectionExtensions.cs b/RavenDB.Identity/ServiceCollectionExtensions.cs index cfd01dd..3b411f1 100644 --- a/RavenDB.Identity/ServiceCollectionExtensions.cs +++ b/RavenDB.Identity/ServiceCollectionExtensions.cs @@ -39,10 +39,10 @@ namespace RavenDB.Identity throw new ArgumentNullException("Connection string cannot be null or empty."); } - var documentStore = new DocumentStore(); - configureAction?.Invoke(documentStore); - + var documentStore = new DocumentStore(); documentStore.ParseConnectionString(connectionString); + documentStore.Conventions.RegisterIdConvention((dbname, commands, user) => "IdentityUsers/" + user.Id); + configureAction?.Invoke(documentStore); documentStore.Initialize(); serviceCollection.AddSingleton(documentStore); @@ -76,25 +76,6 @@ namespace RavenDB.Identity return serviceCollection; } - /// - /// Registers a RavenDB as the user store. - /// - /// The type of user. This should be a class you created derived from . - /// - /// The same service collection so that multiple calls can be chained. - public static IServiceCollection AddRavenDbIdentity(this IServiceCollection services) - where TUser : IdentityUser - { - // Add the AspNet identity system to work with our RavenDB identity objects. - services.AddIdentity() - .AddDefaultTokenProviders(); // options => options.Tokens.ProviderMap.Add("Default", new TokenProviderDescriptor(typeof(UserStore))) - - services.AddScoped, UserStore>(); - services.AddScoped, RoleStore>(); - - return services; - } - /// /// Registers a RavenDB as the user store. /// @@ -102,12 +83,20 @@ namespace RavenDB.Identity /// /// Identity options configuration. /// The same service collection so that multiple calls can be chained. - public static IServiceCollection AddRavenDbIdentity(this IServiceCollection services, Action setupAction) + public static IServiceCollection AddRavenDbIdentity(this IServiceCollection services, Action setupAction = null) where TUser : IdentityUser { // Add the AspNet identity system to work with our RavenDB identity objects. - services.AddIdentity(setupAction) - .AddDefaultTokenProviders(); + if (setupAction != null) + { + services.AddIdentity(setupAction) + .AddDefaultTokenProviders(); + } + else + { + services.AddIdentity() + .AddDefaultTokenProviders(); + } services.AddScoped, UserStore>(); services.AddScoped, RoleStore>(); diff --git a/RavenDB.Identity/UserStore.cs b/RavenDB.Identity/UserStore.cs index 4a91c63..9240331 100644 --- a/RavenDB.Identity/UserStore.cs +++ b/RavenDB.Identity/UserStore.cs @@ -42,7 +42,6 @@ namespace RavenDB.Identity public UserStore(IAsyncDocumentSession session) { this._session = session; - this._session.Advanced.DocumentStore.Conventions.RegisterIdConvention((dbname, commands, user) => "IdentityUsers/" + user.Id); } #region IDispoable implementation