From 041b54b41eece0e63ffa86042c233cb1e5343bc5 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Tue, 26 Jan 2021 14:32:01 +0300 Subject: [PATCH 01/28] Commercial: Add localizations for unsubscribe license expire email page --- .../Commercial/Localization/Resources/en.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index c6eb1ad645..a039d0c7a0 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -34,6 +34,11 @@ "JoinOurMarketingNewsletter": "Join our marketing newsletter", "WouldLikeToReceiveMarketingMaterials": "I would like to receive marketing materials like product deals & special offers.", "StartUsingYourLicenseNow": "Start using your license now!", - "WelcomePage": "Welcome Page" + "WelcomePage": "Welcome Page", + "UnsubscriptionExpireEmail": "Unsubscribe from license expire date reminder emails", + "UnsubscribeLicenseExpireEmailReminderMessage": "This email subscription only contains reminding your license expiration date.", + "UnsubscribeFromLicenseExpireEmails": "If you don't want to receive the emails about your license expiration date, you can unsubscribe at any time you want.", + "Unsubscribe": "Unsubscribe", + "NotOrganizationMember": "You are not member of any organization." } } \ No newline at end of file From 4bc4b75a3861c39b82702a3b20e1eb079bc4fc8a Mon Sep 17 00:00:00 2001 From: EngincanV Date: Tue, 26 Jan 2021 15:04:23 +0300 Subject: [PATCH 02/28] Update en.json --- .../Commercial/Localization/Resources/en.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index a039d0c7a0..4de287778f 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -39,6 +39,8 @@ "UnsubscribeLicenseExpireEmailReminderMessage": "This email subscription only contains reminding your license expiration date.", "UnsubscribeFromLicenseExpireEmails": "If you don't want to receive the emails about your license expiration date, you can unsubscribe at any time you want.", "Unsubscribe": "Unsubscribe", - "NotOrganizationMember": "You are not member of any organization." + "NotOrganizationMember": "You are not member of any organization.", + "UnsubscribeLicenseExpirationEmailSuccessTitle": "Successfully unsubscribed", + "UnsubscribeLicenseExpirationEmailSuccessMessage": "You will not receive license expiration date reminder emails anymore." } } \ No newline at end of file From 37f78fff6b715c2c3de88ed33cde4dff322ccea7 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Sun, 31 Jan 2021 01:32:05 +0000 Subject: [PATCH 03/28] Fix MongoDbRepository DeleteAsync and DeleteManyAsync not setting audit properties or triggering events --- .../Repositories/MongoDB/MongoDbRepository.cs | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index fc520bce81..1495249802 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -277,15 +277,16 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { - await ApplyAbpConceptsForDeletedEntityAsync(entity); - var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); var collection = dbContext.Collection(); - if (entity is ISoftDelete softDeleteEntity && !IsHardDeleted(entity)) + var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); + + if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity)) { - softDeleteEntity.IsDeleted = true; + ((ISoftDelete)entity).IsDeleted = true; + await ApplyAbpConceptsForDeletedEntityAsync(entity); + ReplaceOneResult result; if (dbContext.SessionHandle != null) @@ -313,6 +314,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB } else { + await ApplyAbpConceptsForDeletedEntityAsync(entity); + DeleteResult result; if (dbContext.SessionHandle != null) @@ -343,22 +346,23 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { - var softDeletedEntities = new List(); + var softDeletedEntities = new List<(TEntity Entity, string ConcurrencyStamp)>(); var hardDeletedEntities = new List(); foreach (var entity in entities) { - await ApplyAbpConceptsForDeletedEntityAsync(entity); - SetNewConcurrencyStamp(entity); - if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity)) { - softDeletedEntities.Add(entity); + ((ISoftDelete)entity).IsDeleted = true; + + softDeletedEntities.Add((entity, SetNewConcurrencyStamp(entity))); } else { hardDeletedEntities.Add(entity); } + + await ApplyAbpConceptsForDeletedEntityAsync(entity); } var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); @@ -372,26 +376,23 @@ namespace Volo.Abp.Domain.Repositories.MongoDB if (softDeletedEntities.Count > 0) { - UpdateResult updateResult; - var softDeleteEntitiesCount = softDeletedEntities.Count; + BulkWriteResult updateResult; + + List> replaceRequests = new List>( + softDeletedEntities.Select(entity => new ReplaceOneModel( + CreateEntityFilter(entity.Entity, true, entity.ConcurrencyStamp), entity.Entity)) + ); if (dbContext.SessionHandle != null) { - updateResult = await collection.UpdateManyAsync( - dbContext.SessionHandle, - CreateEntitiesFilter(softDeletedEntities), - Builders.Update.Set(x => ((ISoftDelete)x).IsDeleted, true) - ); + updateResult = await collection.BulkWriteAsync(dbContext.SessionHandle, replaceRequests, cancellationToken: cancellationToken); } else { - updateResult = await collection.UpdateManyAsync( - CreateEntitiesFilter(softDeletedEntities), - Builders.Update.Set(x => ((ISoftDelete)x).IsDeleted, true) - ); + updateResult = await collection.BulkWriteAsync(replaceRequests, cancellationToken: cancellationToken); } - if (updateResult.MatchedCount < softDeleteEntitiesCount) + if (updateResult.MatchedCount < softDeletedEntities.Count) { ThrowOptimisticConcurrencyException(); } @@ -407,13 +408,13 @@ namespace Volo.Abp.Domain.Repositories.MongoDB deleteResult = await collection.DeleteManyAsync( dbContext.SessionHandle, CreateEntitiesFilter(hardDeletedEntities) - ); + ); } else { deleteResult = await collection.DeleteManyAsync( CreateEntitiesFilter(hardDeletedEntities) - ); + ); } if (deleteResult.DeletedCount < hardDeletedEntitiesCount) @@ -780,9 +781,10 @@ namespace Volo.Abp.Domain.Repositories.MongoDB return RepositoryFilterer.CreateEntityFilter(entity, withConcurrencyStamp, concurrencyStamp); } + // todo: This method should consider concurrencyStamp protected override FilterDefinition CreateEntitiesFilter(IEnumerable entities, bool withConcurrencyStamp = false) { - return RepositoryFilterer.CreateEntitiesFilter(entities, withConcurrencyStamp); + return RepositoryFilterer.CreateEntitiesFilter(entities); } } } From 2f69058e67f3bde89e966278aa8fd1071c35cc37 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Sun, 31 Jan 2021 01:33:20 +0000 Subject: [PATCH 04/28] Add additional DeleteManyAsync soft-delete test --- .../Abp/TestApp/Testing/SoftDelete_Tests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs index b8618fd6a3..4b313d2127 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs @@ -56,6 +56,23 @@ namespace Volo.Abp.TestApp.Testing douglas.DeletionTime.ShouldNotBeNull(); } } + + [Fact] + public async Task Should_Cancel_Deletion_For_Soft_Delete_Many_Entities_ById() + { + await PersonRepository.DeleteManyAsync(new []{ TestDataBuilder.UserDouglasId }); + + var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); + douglas.ShouldBeNull(); + + using (DataFilter.Disable()) + { + douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); + douglas.ShouldNotBeNull(); + douglas.IsDeleted.ShouldBeTrue(); + douglas.DeletionTime.ShouldNotBeNull(); + } + } [Fact] public async Task Should_Handle_Deletion_On_Update_For_Soft_Delete_Entities() From 6c0ee78d14462eb9aa8f63ac04ebe1002d8a54a6 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Sun, 31 Jan 2021 01:55:45 +0000 Subject: [PATCH 05/28] Update Repository DeleteAsync and DeleteManyAsync methods * Add RepositoryBase.DeleteManyAsync(predicate) * Call DeleteManyAsync(predicate) in concrete DeleteAsync(predicate) implementations when possible Requires this PR for tests to pass: https://github.com/abpframework/abp/pull/7542 --- .../Abp/Domain/Repositories/RepositoryBase.cs | 6 +++++ .../EntityFrameworkCore/EfCoreRepository.cs | 5 +--- .../MemoryDb/MemoryDbRepository.cs | 23 ++++++++----------- .../Repositories/MongoDB/MongoDbRepository.cs | 5 +--- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs index 0b32d54d45..d1bf2aa754 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -85,6 +85,12 @@ namespace Volo.Abp.Domain.Repositories public abstract Task DeleteAsync(Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default); + public virtual Task DeleteManyAsync( + Expression> predicate, + bool autoSave = false, + CancellationToken cancellationToken = default) + => DeleteAsync(predicate, autoSave, cancellationToken); + protected virtual TQueryable ApplyDataFilters(TQueryable query) where TQueryable : IQueryable { diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs index 055c9c2de9..d673ff2c28 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs @@ -289,10 +289,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore .Where(predicate) .ToListAsync(GetCancellationToken(cancellationToken)); - foreach (var entity in entities) - { - dbSet.Remove(entity); - } + await DeleteManyAsync(entities, autoSave, cancellationToken); if (autoSave) { diff --git a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs index 8ab6753de3..bb7d64bcc1 100644 --- a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs +++ b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs @@ -184,19 +184,6 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb return (await GetQueryableAsync()).Where(predicate).SingleOrDefault(); } - public override async Task DeleteAsync( - Expression> predicate, - bool autoSave = false, - CancellationToken cancellationToken = default) - { - var entities = (await GetQueryableAsync()).Where(predicate).ToList(); - - foreach (var entity in entities) - { - await DeleteAsync(entity, autoSave, cancellationToken); - } - } - public override async Task InsertAsync( TEntity entity, bool autoSave = false, @@ -251,6 +238,16 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb } } + public override async Task DeleteAsync( + Expression> predicate, + bool autoSave = false, + CancellationToken cancellationToken = default) + { + var entities = (await GetQueryableAsync()).Where(predicate).ToList(); + + await DeleteManyAsync(entities, autoSave, cancellationToken); + } + public override async Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) { return (await GetQueryableAsync()).ToList(); diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index 1495249802..efdd0a8991 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -463,10 +463,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB .Where(predicate) .ToListAsync(cancellationToken); - foreach (var entity in entities) - { - await DeleteAsync(entity, autoSave, cancellationToken); - } + await DeleteManyAsync(entities, autoSave, cancellationToken); } [Obsolete("Use GetQueryableAsync method.")] From bf5c64e768c20af27b1aec52030ff1cfb62120b0 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Sun, 31 Jan 2021 02:35:56 +0000 Subject: [PATCH 06/28] Add IRepository.DeleteManyAsync declaration --- .../Abp/Domain/Repositories/IRepository.cs | 23 +++++++++++++++---- .../Abp/Domain/Repositories/RepositoryBase.cs | 5 +--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs index 3bda51bd2e..ec79597396 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs @@ -20,8 +20,10 @@ namespace Volo.Abp.Domain.Repositories { /// /// Get a single entity by the given . - /// It returns null if no entity with the given . + /// + /// It returns null if there is no entity with the given . /// It throws if there are multiple entities with the given . + /// /// /// A condition to find the entity /// Set true to include all children of this entity @@ -34,8 +36,10 @@ namespace Volo.Abp.Domain.Repositories /// /// Get a single entity by the given . + /// /// It throws if there is no entity with the given . /// It throws if there are multiple entities with the given . + /// /// /// A condition to filter entities /// Set true to include all children of this entity @@ -47,10 +51,11 @@ namespace Volo.Abp.Domain.Repositories ); /// - /// Deletes many entities by function. - /// Notice that: All entities fits to given predicate are retrieved and deleted. - /// This may cause major performance problems if there are too many entities with - /// given predicate. + /// Deletes many entities by the given . + /// + /// Please note: This may cause major performance problems if there are too many entities returned for a + /// given predicate and the database provider doesn't have a way to efficiently delete many entities. + /// /// /// A condition to filter entities /// @@ -63,6 +68,14 @@ namespace Volo.Abp.Domain.Repositories bool autoSave = false, CancellationToken cancellationToken = default ); + + /// + /// This is an alias for + Task DeleteManyAsync( + [NotNull] Expression> predicate, + bool autoSave = false, + CancellationToken cancellationToken = default + ); } public interface IRepository : IRepository, IReadOnlyRepository, IBasicRepository diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs index d1bf2aa754..5ba522ef00 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -85,10 +85,7 @@ namespace Volo.Abp.Domain.Repositories public abstract Task DeleteAsync(Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default); - public virtual Task DeleteManyAsync( - Expression> predicate, - bool autoSave = false, - CancellationToken cancellationToken = default) + public virtual Task DeleteManyAsync(Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default) => DeleteAsync(predicate, autoSave, cancellationToken); protected virtual TQueryable ApplyDataFilters(TQueryable query) From adebfb958d8d5ea3b744452b866f09d4ad094974 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 1 Feb 2021 15:15:42 +0800 Subject: [PATCH 07/28] Use eager loading for GetAssemblies of FolderPlugInSource. https://github.com/abpframework/abp/pull/7538 --- .../Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs index b0544d0338..eb54a19900 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs @@ -18,7 +18,7 @@ namespace Volo.Abp.Modularity.PlugIns public Func Filter { get; set; } public FolderPlugInSource( - [NotNull] string folder, + [NotNull] string folder, SearchOption searchOption = SearchOption.TopDirectoryOnly) { Check.NotNull(folder, nameof(folder)); @@ -52,7 +52,7 @@ namespace Volo.Abp.Modularity.PlugIns return modules.ToArray(); } - private IEnumerable GetAssemblies() + private List GetAssemblies() { var assemblyFiles = AssemblyHelper.GetAssemblyFiles(Folder, SearchOption); @@ -61,7 +61,7 @@ namespace Volo.Abp.Modularity.PlugIns assemblyFiles = assemblyFiles.Where(Filter); } - return assemblyFiles.Select(AssemblyLoadContext.Default.LoadFromAssemblyPath); + return assemblyFiles.Select(AssemblyLoadContext.Default.LoadFromAssemblyPath).ToList(); } } -} \ No newline at end of file +} From 18205a8935e6069c0cd3586846b3472b5f6e1406 Mon Sep 17 00:00:00 2001 From: enisn Date: Mon, 1 Feb 2021 12:29:01 +0300 Subject: [PATCH 08/28] CmsKit - Add missing Http method binding to TagDefinitions --- .../Volo/CmsKit/Admin/Tags/TagAdminController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs index afc9a83fc8..4655c60bd6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs @@ -62,6 +62,8 @@ namespace Volo.CmsKit.Admin.Tags return TagAdminAppService.UpdateAsync(id, input); } + [HttpGet] + [Route("tag-definitions")] public Task> GetTagDefinitionsAsync() { return TagAdminAppService.GetTagDefinitionsAsync(); From e910950e847591a411f68f54cfc58d4163967d14 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 1 Feb 2021 11:59:39 +0100 Subject: [PATCH 09/28] Update Blazorise 0.9.3-preview8 --- .../src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj | 6 +++--- .../MyCompanyName.MyProjectName.Blazor.csproj | 4 ++-- .../MyCompanyName.MyProjectName.Blazor.Host.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj index 9405337b89..3f41412a9e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj +++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj index 96a8f791ee..bdb87e04c7 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj index 57625cfd81..b166dc8898 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj @@ -8,8 +8,8 @@ - - + + From 16cbf7c188cd22e566c8adf28825a154c7abbb25 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 1 Feb 2021 21:17:55 +0800 Subject: [PATCH 10/28] Update PostgreSQL connecting string. https://github.com/npgsql/npgsql/blob/058b52af600d88cb5dbbee16140812dd3fdd8f85/src/Npgsql/NpgsqlConnectionStringBuilder.cs#L786 https://github.com/npgsql/npgsql/blob/058b52af600d88cb5dbbee16140812dd3fdd8f85/src/Npgsql/NpgsqlConnectionStringBuilder.cs#L764 --- .../Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs index 32e09b3339..b0da7f9db0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.Cli.Commands.Services case DatabaseManagementSystem.MySQL: return "Server=localhost;Port=3306;Database=MyProjectName;Uid=root;Pwd=myPassword;"; case DatabaseManagementSystem.PostgreSQL: - return "User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=MyProjectName;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;"; + return "Host=localhost;Port=5432;Database=MyProjectName;User ID=root;Password=myPassword;Pooling=true;MinimumPoolSize=0;MaximumPoolSize=100;Connection Lifetime=0;"; //case DatabaseManagementSystem.Oracle: case DatabaseManagementSystem.OracleDevart: return "Data Source=MyProjectName;Integrated Security=yes;"; From 7e366398d3738f80591467ac4c71bacafd816e01 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Mon, 1 Feb 2021 16:54:11 +0300 Subject: [PATCH 11/28] fix page routing. --- .../src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs | 6 ++---- .../Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs index 8cb5644256..7833e6aa3e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs @@ -1,5 +1,4 @@ -using System.Linq; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AutoMapper; @@ -61,8 +60,7 @@ namespace Volo.CmsKit.Public.Web { if (GlobalFeatureManager.Instance.IsEnabled()) { - // TODO: Work on this route logic. Blocks some routes with this logic. - options.Conventions.AddPageRoute("/CmsKit/Pages/Index", "/{*pageUrl}"); + options.Conventions.AddPageRoute("/CmsKit/Pages/Index", @"/{pageUrl}"); } }); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml index 73c7637b01..c31edaaba8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml @@ -1,4 +1,4 @@ -@page "{*pageUrl}" +@page "{pageUrl}" @using Microsoft.AspNetCore.Mvc.Localization @using Volo.CmsKit.Localization @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages From 792af17439fd231f359d4fc34e161b5c9f3eb7df Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 1 Feb 2021 21:59:34 +0800 Subject: [PATCH 12/28] Insert the modal after the existing one. --- .../bootstrap/modal-manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index a4d32550f8..75d080feda 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js @@ -39,7 +39,7 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f var _$modal = null; var _$form = null; - var _modalId = 'Modal_' + (Math.floor((Math.random() * 1000000))) + new Date().getTime(); + var _modalId = 'Abp_Modal_' + (Math.floor((Math.random() * 1000000))) + new Date().getTime(); var _modalObject = null; var _publicApi = null; @@ -56,7 +56,12 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f function _createContainer() { _removeContainer(); _$modalContainer = $('
'); - $('body').prepend(_$modalContainer); + var existsModals = $('[id^="Abp_Modal_"]'); + if (existsModals.length) { + existsModals.last().after(_$modalContainer) + } else { + $('body').prepend(_$modalContainer); + } return _$modalContainer; } From d48e65d23ed912c1e554e4fb49ace48e4ac3e87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 1 Feb 2021 20:46:43 +0300 Subject: [PATCH 13/28] Introduce ITenantDatabaseSchemaMigrator. --- .../NullTenantDatabaseSchemaMigrator.cs | 13 +++++++++++++ .../MultiTenancy/TenantDatabaseSchemaMigrator.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs create mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs new file mode 100644 index 0000000000..7d5e76f11b --- /dev/null +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.MultiTenancy +{ + public class NullTenantDatabaseSchemaMigrator : ITenantDatabaseSchemaMigrator, ISingletonDependency + { + public Task MigrateAsync() + { + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs new file mode 100644 index 0000000000..e6fef5c427 --- /dev/null +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.MultiTenancy +{ + public interface ITenantDatabaseSchemaMigrator + { + /// + /// Set Current Tenant before calling this method. + /// + /// + Task MigrateAsync(); + } +} From 8762284482449c85903c5fd40a10b9b82cb0474e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 1 Feb 2021 20:53:42 +0300 Subject: [PATCH 14/28] Added Volo.Abp.EventBus.Abstractions package. --- framework/Volo.Abp.sln | 7 +++++ .../FodyWeavers.xml | 3 ++ .../FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.EventBus.Abstractions.csproj | 15 ++++++++++ .../AbpEventBusAbstractionsModule.cs | 9 ++++++ .../Volo/Abp/EventBus/EventNameAttribute.cs | 0 .../Abp/EventBus/GenericEventNameAttribute.cs | 0 .../Volo/Abp/EventBus/IEventNameProvider.cs | 0 .../Volo.Abp.EventBus.csproj | 2 +- .../Volo/Abp/EventBus/AbpEventBusModule.cs | 5 +++- nupkg/common.ps1 | 1 + 11 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj create mode 100644 framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs rename framework/src/{Volo.Abp.EventBus => Volo.Abp.EventBus.Abstractions}/Volo/Abp/EventBus/EventNameAttribute.cs (100%) rename framework/src/{Volo.Abp.EventBus => Volo.Abp.EventBus.Abstractions}/Volo/Abp/EventBus/GenericEventNameAttribute.cs (100%) rename framework/src/{Volo.Abp.EventBus => Volo.Abp.EventBus.Abstractions}/Volo/Abp/EventBus/IEventNameProvider.cs (100%) diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 963472ada8..8c2670fa27 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -359,6 +359,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Json.Tests", "test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Tests", "test\Volo.Abp.Http.Tests\Volo.Abp.Http.Tests.csproj", "{A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Abstractions", "src\Volo.Abp.EventBus.Abstractions\Volo.Abp.EventBus.Abstractions.csproj", "{8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1069,6 +1071,10 @@ Global {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Release|Any CPU.Build.0 = Release|Any CPU + {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1250,6 +1256,7 @@ Global {DD9519E0-5A68-48DC-A051-7BF2AC922F3E} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {00D07595-993C-40FC-BD90-0DD6331414D3} = {447C8A77-E5F0-4538-8687-7383196D04EA} {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml new file mode 100644 index 0000000000..bc5a74a236 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj b/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj new file mode 100644 index 0000000000..ae0cef7f59 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj @@ -0,0 +1,15 @@ + + + + + + + netstandard2.0 + + + + + + + + diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs new file mode 100644 index 0000000000..bb9d4585b9 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.EventBus.Abstractions +{ + public class AbpEventBusAbstractionsModule : AbpModule + { + + } +} diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventNameAttribute.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/EventNameAttribute.cs similarity index 100% rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventNameAttribute.cs rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/EventNameAttribute.cs diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/GenericEventNameAttribute.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/GenericEventNameAttribute.cs similarity index 100% rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/GenericEventNameAttribute.cs rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/GenericEventNameAttribute.cs diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventNameProvider.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/IEventNameProvider.cs similarity index 100% rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventNameProvider.cs rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/IEventNameProvider.cs diff --git a/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj b/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj index a1799c6673..221454bed3 100644 --- a/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj +++ b/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj @@ -15,7 +15,7 @@ - + diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs index 81c3393a50..eb9c17b129 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; +using Volo.Abp.EventBus.Abstractions; using Volo.Abp.EventBus.Distributed; using Volo.Abp.EventBus.Local; using Volo.Abp.Modularity; @@ -9,7 +10,9 @@ using Volo.Abp.Reflection; namespace Volo.Abp.EventBus { - [DependsOn(typeof(AbpMultiTenancyModule))] + [DependsOn( + typeof(AbpEventBusAbstractionsModule), + typeof(AbpMultiTenancyModule))] public class AbpEventBusModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 29249ef3f4..16f13513ee 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -91,6 +91,7 @@ $projects = ( "framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql", "framework/src/Volo.Abp.EntityFrameworkCore.Sqlite", "framework/src/Volo.Abp.EntityFrameworkCore.SqlServer", + "framework/src/Volo.Abp.EventBus.Abstractions", "framework/src/Volo.Abp.EventBus", "framework/src/Volo.Abp.EventBus.RabbitMQ", "framework/src/Volo.Abp.EventBus.Kafka", From 6d50fc998d4ed8238fa5495c6f2299a22a579f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 1 Feb 2021 20:54:25 +0300 Subject: [PATCH 15/28] Define TenantCreatedEto --- .../Volo.Abp.MultiTenancy.csproj | 1 + .../Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs | 4 +++- .../Volo/Abp/MultiTenancy/TenantCreatedEto.cs | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj b/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj index 951712c7f0..344dbfdec0 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj +++ b/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj @@ -16,6 +16,7 @@ + diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs index 9dc64ef7f8..c51daf99aa 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Data; +using Volo.Abp.EventBus.Abstractions; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy.ConfigurationStore; using Volo.Abp.Security; @@ -10,7 +11,8 @@ namespace Volo.Abp.MultiTenancy [DependsOn( typeof(AbpDataModule), - typeof(AbpSecurityModule) + typeof(AbpSecurityModule), + typeof(AbpEventBusAbstractionsModule) )] public class AbpMultiTenancyModule : AbpModule { diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs new file mode 100644 index 0000000000..6cd1544d8c --- /dev/null +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs @@ -0,0 +1,13 @@ +using System; +using Volo.Abp.EventBus; + +namespace Volo.Abp.MultiTenancy +{ + [EventName("abp.multi_tenancy.tenant.created")] + public class TenantCreatedEto + { + public Guid Id { get; set; } + + public string Name { get; set; } + } +} From f4458ac7d039c531dfe0b5dbdd91ddbd121eded5 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Feb 2021 10:56:04 +0800 Subject: [PATCH 16/28] Remove DeleteManyAsync from IRepository. --- .../Volo/Abp/Domain/Repositories/IRepository.cs | 12 ++---------- .../Volo/Abp/Domain/Repositories/RepositoryBase.cs | 3 --- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs index ec79597396..f1136c4ea2 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs @@ -53,7 +53,7 @@ namespace Volo.Abp.Domain.Repositories /// /// Deletes many entities by the given . /// - /// Please note: This may cause major performance problems if there are too many entities returned for a + /// Please note: This may cause major performance problems if there are too many entities returned for a /// given predicate and the database provider doesn't have a way to efficiently delete many entities. /// /// @@ -68,18 +68,10 @@ namespace Volo.Abp.Domain.Repositories bool autoSave = false, CancellationToken cancellationToken = default ); - - /// - /// This is an alias for - Task DeleteManyAsync( - [NotNull] Expression> predicate, - bool autoSave = false, - CancellationToken cancellationToken = default - ); } public interface IRepository : IRepository, IReadOnlyRepository, IBasicRepository where TEntity : class, IEntity { } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs index 5ba522ef00..0b32d54d45 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -85,9 +85,6 @@ namespace Volo.Abp.Domain.Repositories public abstract Task DeleteAsync(Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default); - public virtual Task DeleteManyAsync(Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default) - => DeleteAsync(predicate, autoSave, cancellationToken); - protected virtual TQueryable ApplyDataFilters(TQueryable query) where TQueryable : IQueryable { From 467ed0627d73750e076c17477105181ac5c0e54e Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Feb 2021 13:44:29 +0800 Subject: [PATCH 17/28] Minor changes --- .../MemoryDb/MemoryDbRepository.cs | 20 ++--- .../Repositories/MongoDB/MongoDbRepository.cs | 77 +++++++++++-------- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs index bb7d64bcc1..fd8c5afd16 100644 --- a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs +++ b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs @@ -184,6 +184,16 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb return (await GetQueryableAsync()).Where(predicate).SingleOrDefault(); } + public override async Task DeleteAsync( + Expression> predicate, + bool autoSave = false, + CancellationToken cancellationToken = default) + { + var entities = (await GetQueryableAsync()).Where(predicate).ToList(); + + await DeleteManyAsync(entities, autoSave, cancellationToken); + } + public override async Task InsertAsync( TEntity entity, bool autoSave = false, @@ -238,16 +248,6 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb } } - public override async Task DeleteAsync( - Expression> predicate, - bool autoSave = false, - CancellationToken cancellationToken = default) - { - var entities = (await GetQueryableAsync()).Where(predicate).ToList(); - - await DeleteManyAsync(entities, autoSave, cancellationToken); - } - public override async Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) { return (await GetQueryableAsync()).ToList(); diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index efdd0a8991..e6030246aa 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -71,16 +71,18 @@ namespace Volo.Abp.Domain.Repositories.MongoDB protected Task GetDbContextAsync(CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + // Multi-tenancy unaware entities should always use the host connection string if (!EntityHelper.IsMultiTenant()) { using (CurrentTenant.Change(null)) { - return DbContextProvider.GetDbContextAsync(GetCancellationToken(cancellationToken)); + return DbContextProvider.GetDbContextAsync(cancellationToken); } } - return DbContextProvider.GetDbContextAsync(GetCancellationToken(cancellationToken)); + return DbContextProvider.GetDbContextAsync(cancellationToken); } protected IMongoDbContextProvider DbContextProvider { get; } @@ -107,9 +109,11 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + await ApplyAbpConceptsForAddedEntityAsync(entity); - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); if (dbContext.SessionHandle != null) @@ -117,14 +121,14 @@ namespace Volo.Abp.Domain.Repositories.MongoDB await collection.InsertOneAsync( dbContext.SessionHandle, entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } else { await collection.InsertOneAsync( entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } @@ -133,6 +137,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB public override async Task InsertManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + var entityArray = entities.ToArray(); foreach (var entity in entityArray) @@ -140,7 +146,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB await ApplyAbpConceptsForAddedEntityAsync(entity); } - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); if (BulkOperationProvider != null) @@ -169,6 +175,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + SetModificationAuditProperties(entity); if (entity is ISoftDelete softDeleteEntity && softDeleteEntity.IsDeleted) @@ -186,7 +194,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); ReplaceOneResult result; - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); if (dbContext.SessionHandle != null) @@ -195,7 +203,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB dbContext.SessionHandle, CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } else @@ -203,7 +211,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB result = await collection.ReplaceOneAsync( CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } @@ -277,7 +285,9 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); + cancellationToken = GetCancellationToken(cancellationToken); + + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); var oldConcurrencyStamp = SetNewConcurrencyStamp(entity); @@ -295,7 +305,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB dbContext.SessionHandle, CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } else @@ -303,7 +313,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB result = await collection.ReplaceOneAsync( CreateEntityFilter(entity, true, oldConcurrencyStamp), entity, - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } @@ -323,14 +333,14 @@ namespace Volo.Abp.Domain.Repositories.MongoDB result = await collection.DeleteOneAsync( dbContext.SessionHandle, CreateEntityFilter(entity, true, oldConcurrencyStamp), - cancellationToken: GetCancellationToken(cancellationToken) + cancellationToken: cancellationToken ); } else { result = await collection.DeleteOneAsync( CreateEntityFilter(entity, true, oldConcurrencyStamp), - GetCancellationToken(cancellationToken) + cancellationToken ); } @@ -346,7 +356,9 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool autoSave = false, CancellationToken cancellationToken = default) { - var softDeletedEntities = new List<(TEntity Entity, string ConcurrencyStamp)>(); + cancellationToken = GetCancellationToken(cancellationToken); + + var softDeletedEntities = new Dictionary(); var hardDeletedEntities = new List(); foreach (var entity in entities) @@ -355,7 +367,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB { ((ISoftDelete)entity).IsDeleted = true; - softDeletedEntities.Add((entity, SetNewConcurrencyStamp(entity))); + softDeletedEntities.Add(entity, SetNewConcurrencyStamp(entity)); } else { @@ -365,12 +377,12 @@ namespace Volo.Abp.Domain.Repositories.MongoDB await ApplyAbpConceptsForDeletedEntityAsync(entity); } - var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken)); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); if (BulkOperationProvider != null) { - await BulkOperationProvider.DeleteManyAsync(this, entities.ToArray(), dbContext.SessionHandle, autoSave, cancellationToken); + await BulkOperationProvider.DeleteManyAsync(this, entities, dbContext.SessionHandle, autoSave, cancellationToken); return; } @@ -378,9 +390,9 @@ namespace Volo.Abp.Domain.Repositories.MongoDB { BulkWriteResult updateResult; - List> replaceRequests = new List>( + var replaceRequests = new List>( softDeletedEntities.Select(entity => new ReplaceOneModel( - CreateEntityFilter(entity.Entity, true, entity.ConcurrencyStamp), entity.Entity)) + CreateEntityFilter(entity.Key, true, entity.Value), entity.Key)) ); if (dbContext.SessionHandle != null) @@ -407,14 +419,14 @@ namespace Volo.Abp.Domain.Repositories.MongoDB { deleteResult = await collection.DeleteManyAsync( dbContext.SessionHandle, - CreateEntitiesFilter(hardDeletedEntities) - ); + CreateEntitiesFilter(hardDeletedEntities), + cancellationToken: cancellationToken); } else { deleteResult = await collection.DeleteManyAsync( - CreateEntitiesFilter(hardDeletedEntities) - ); + CreateEntitiesFilter(hardDeletedEntities), + cancellationToken: cancellationToken); } if (deleteResult.DeletedCount < hardDeletedEntitiesCount) @@ -482,9 +494,11 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool includeDetails = true, CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + return await (await GetMongoQueryableAsync(cancellationToken)) .Where(predicate) - .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)); + .SingleOrDefaultAsync(cancellationToken); } [Obsolete("Use GetMongoQueryableAsync method.")] @@ -499,6 +513,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB public async Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = dbContext.Collection(); @@ -511,6 +527,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB public async Task> GetAggregateAsync(CancellationToken cancellationToken = default) { + cancellationToken = GetCancellationToken(cancellationToken); + var dbContext = await GetDbContextAsync(cancellationToken); var collection = await GetCollectionAsync(cancellationToken); @@ -693,13 +711,13 @@ namespace Volo.Abp.Domain.Repositories.MongoDB [Obsolete("This method will be removed in future versions.")] public IAsyncCursor ToCursor(CancellationToken cancellationToken = new CancellationToken()) { - return GetMongoQueryable().ToCursor(cancellationToken); + return GetMongoQueryable().ToCursor(GetCancellationToken(cancellationToken)); } [Obsolete("This method will be removed in future versions.")] public Task> ToCursorAsync(CancellationToken cancellationToken = new CancellationToken()) { - return GetMongoQueryable().ToCursorAsync(cancellationToken); + return GetMongoQueryable().ToCursorAsync(GetCancellationToken(cancellationToken)); } } @@ -722,7 +740,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB bool includeDetails = true, CancellationToken cancellationToken = default) { - var entity = await FindAsync(id, includeDetails, cancellationToken); + var entity = await FindAsync(id, includeDetails, GetCancellationToken(cancellationToken)); if (entity == null) { @@ -778,10 +796,9 @@ namespace Volo.Abp.Domain.Repositories.MongoDB return RepositoryFilterer.CreateEntityFilter(entity, withConcurrencyStamp, concurrencyStamp); } - // todo: This method should consider concurrencyStamp protected override FilterDefinition CreateEntitiesFilter(IEnumerable entities, bool withConcurrencyStamp = false) { - return RepositoryFilterer.CreateEntitiesFilter(entities); + return RepositoryFilterer.CreateEntitiesFilter(entities, withConcurrencyStamp); } } } From a8b4e0dfa9bea041f674d2a92aadd3498913cc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 2 Feb 2021 11:31:21 +0300 Subject: [PATCH 18/28] Seed identity & permission data for a tenant via event handlers. --- .../Entities/Events/Distributed/EtoBase.cs | 0 .../Volo/Abp/MultiTenancy/TenantCreatedEto.cs | 4 +- .../Abp/Identity/AbpIdentityDomainModule.cs | 18 ++++- .../Volo/Abp/Identity/AbpIdentityOptions.cs | 5 ++ .../Volo/Abp/Identity/IdentityDataSeeder.cs | 79 ++++++++++--------- .../Identity/IdentityTenantCreatedHandler.cs | 32 ++++++++ .../Abp/Identity/PasswordOptionsExtensions.cs | 35 ++++++++ .../AbpPermissionManagementDomainModule.cs | 23 +++++- .../PermissionDataSeedContributor.cs | 1 - .../PermissionManagementOptions.cs | 6 +- .../PermissionTenantCreatedHandler.cs | 38 +++++++++ 11 files changed, 197 insertions(+), 44 deletions(-) rename framework/src/{Volo.Abp.Ddd.Domain => Volo.Abp.EventBus.Abstractions}/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs (100%) create mode 100644 modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs create mode 100644 modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs create mode 100644 modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs similarity index 100% rename from framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs index 6cd1544d8c..317995c971 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs @@ -1,10 +1,12 @@ using System; +using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.EventBus; namespace Volo.Abp.MultiTenancy { + [Serializable] [EventName("abp.multi_tenancy.tenant.created")] - public class TenantCreatedEto + public class TenantCreatedEto : EtoBase { public Guid Id { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs index 4269ae2e01..6c2197b38d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs @@ -1,10 +1,12 @@ -using Microsoft.AspNetCore.Identity; +using System.Collections.Generic; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Volo.Abp.AutoMapper; using Volo.Abp.Domain; using Volo.Abp.Domain.Entities.Events.Distributed; +using Volo.Abp.EventBus.Distributed; using Volo.Abp.Modularity; using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending.Modularity; @@ -57,6 +59,20 @@ namespace Volo.Abp.Identity }); context.Services.AddAbpDynamicOptions(); + + Configure(options => + { + var serviceProvider = context.Services.GetServiceProviderOrNull(); + if (serviceProvider != null) + { + var abpIdentityOptions = serviceProvider.GetRequiredService>().Value; + if (!abpIdentityOptions.IsDistributedEventHandlingEnabled) + { + var identityDomainAssembly = typeof(AbpIdentityDomainModule).Assembly; + options.Handlers.RemoveAll(x => x.Assembly == identityDomainAssembly); + } + } + }); } public override void PostConfigureServices(ServiceConfigurationContext context) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs index 6cfaf75c0c..36b7ba587a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs @@ -4,6 +4,11 @@ { public ExternalLoginProviderDictionary ExternalLoginProviders { get; } + /// + /// Default: true. + /// + public bool IsDistributedEventHandlingEnabled { get; } = true; + public AbpIdentityOptions() { ExternalLoginProviders = new ExternalLoginProviderDictionary(); diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs index f6bed1b914..9051dc7d66 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs @@ -49,58 +49,61 @@ namespace Volo.Abp.Identity Check.NotNullOrWhiteSpace(adminEmail, nameof(adminEmail)); Check.NotNullOrWhiteSpace(adminPassword, nameof(adminPassword)); - await IdentityOptions.SetAsync(); - - var result = new IdentityDataSeedResult(); - using (CurrentTenant.Change(tenantId)) { - //"admin" user - const string adminUserName = "admin"; - var adminUser = await UserRepository.FindByNormalizedUserNameAsync( - LookupNormalizer.NormalizeName(adminUserName) - ); + await IdentityOptions.SetAsync(); - if (adminUser != null) + using (IdentityOptions.Value.Password.ClearRequirements()) { - return result; - } + var result = new IdentityDataSeedResult(); + //"admin" user + const string adminUserName = "admin"; + var adminUser = await UserRepository.FindByNormalizedUserNameAsync( + LookupNormalizer.NormalizeName(adminUserName) + ); - adminUser = new IdentityUser( - GuidGenerator.Create(), - adminUserName, - adminEmail, - tenantId - ) - { - Name = adminUserName - }; - - (await UserManager.CreateAsync(adminUser, adminPassword)).CheckErrors(); - result.CreatedAdminUser = true; + if (adminUser != null) + { + return result; + } - //"admin" role - const string adminRoleName = "admin"; - var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(adminRoleName)); - if (adminRole == null) - { - adminRole = new IdentityRole( + adminUser = new IdentityUser( GuidGenerator.Create(), - adminRoleName, + adminUserName, + adminEmail, tenantId ) { - IsStatic = true, - IsPublic = true + Name = adminUserName }; - (await RoleManager.CreateAsync(adminRole)).CheckErrors(); - result.CreatedAdminRole = true; - } + (await UserManager.CreateAsync(adminUser, adminPassword)).CheckErrors(); + result.CreatedAdminUser = true; + + //"admin" role + const string adminRoleName = "admin"; + var adminRole = + await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(adminRoleName)); + if (adminRole == null) + { + adminRole = new IdentityRole( + GuidGenerator.Create(), + adminRoleName, + tenantId + ) + { + IsStatic = true, + IsPublic = true + }; - (await UserManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors(); + (await RoleManager.CreateAsync(adminRole)).CheckErrors(); + result.CreatedAdminRole = true; + } - return result; + (await UserManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors(); + + return result; + } } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs new file mode 100644 index 0000000000..92a0be629c --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs @@ -0,0 +1,32 @@ +using System.Threading.Tasks; +using AutoMapper.Internal; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; + +namespace Volo.Abp.Identity +{ + public class IdentityTenantCreatedHandler : IDistributedEventHandler, ITransientDependency + { + public ILogger Logger { get; set; } + + protected IIdentityDataSeeder IdentityDataSeeder { get; } + + public IdentityTenantCreatedHandler(IIdentityDataSeeder identityDataSeeder) + { + IdentityDataSeeder = identityDataSeeder; + Logger = NullLogger.Instance; + } + + public async Task HandleEventAsync(TenantCreatedEto eventData) + { + await IdentityDataSeeder.SeedAsync( + eventData.Properties.GetOrDefault("AdminEmail") as string ?? "admin@abp.io", + eventData.Properties.GetOrDefault("AdminPassword") as string ?? "1q2w3E*", + eventData.Id + ); + } + } +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs new file mode 100644 index 0000000000..793cc6349e --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs @@ -0,0 +1,35 @@ +using System; +using Microsoft.AspNetCore.Identity; + +namespace Volo.Abp.Identity +{ + public static class PasswordOptionsExtensions + { + public static IDisposable ClearRequirements(this PasswordOptions options) + { + var oldRequireDigit = options.RequireDigit; + var oldRequiredLength = options.RequiredLength; + var oldRequireLowercase = options.RequireLowercase; + var oldRequireUppercase = options.RequireUppercase; + var oldRequiredUniqueChars = options.RequiredUniqueChars; + var oldRequireNonAlphanumeric = options.RequireNonAlphanumeric; + + options.RequireDigit = false; + options.RequiredLength = 1; + options.RequireLowercase = false; + options.RequireUppercase = false; + options.RequiredUniqueChars = 1; + options.RequireNonAlphanumeric = false; + + return new DisposeAction(() => + { + options.RequireDigit = oldRequireDigit; + options.RequiredLength = oldRequiredLength; + options.RequireLowercase = oldRequireLowercase; + options.RequireUppercase = oldRequireUppercase; + options.RequiredUniqueChars = oldRequiredUniqueChars; + options.RequireNonAlphanumeric = oldRequireNonAlphanumeric; + }); + } + } +} diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs index c199a2130b..5b3eb9f40f 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs @@ -1,6 +1,10 @@ -using Volo.Abp.Authorization; +using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.Authorization; using Volo.Abp.Caching; using Volo.Abp.Domain; +using Volo.Abp.EventBus.Distributed; using Volo.Abp.Json; using Volo.Abp.Modularity; @@ -13,6 +17,21 @@ namespace Volo.Abp.PermissionManagement [DependsOn(typeof(AbpJsonModule))] public class AbpPermissionManagementDomainModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + var serviceProvider = context.Services.GetServiceProviderOrNull(); + if (serviceProvider != null) + { + var abpIdentityOptions = serviceProvider.GetRequiredService>().Value; + if (!abpIdentityOptions.IsDistributedEventHandlingEnabled) + { + var identityDomainAssembly = typeof(AbpPermissionManagementDomainModule).Assembly; + options.Handlers.RemoveAll(x => x.Assembly == identityDomainAssembly); + } + } + }); + } } } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs index ac8274d445..8260df895f 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs @@ -10,7 +10,6 @@ namespace Volo.Abp.PermissionManagement public class PermissionDataSeedContributor : IDataSeedContributor, ITransientDependency { protected ICurrentTenant CurrentTenant { get; } - protected IPermissionDefinitionManager PermissionDefinitionManager { get; } protected IPermissionDataSeeder PermissionDataSeeder { get; } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs index 674f5daa88..c36cde49ee 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs @@ -5,11 +5,15 @@ namespace Volo.Abp.PermissionManagement { public class PermissionManagementOptions { - //TODO: rename to Providers public ITypeList ManagementProviders { get; } public Dictionary ProviderPolicies { get; } + /// + /// Default: true. + /// + public bool IsDistributedEventHandlingEnabled { get; } = true; + public PermissionManagementOptions() { ManagementProviders = new TypeList(); diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs new file mode 100644 index 0000000000..8962574434 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs @@ -0,0 +1,38 @@ +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; + +namespace Volo.Abp.PermissionManagement +{ + public class PermissionTenantCreatedHandler : IDistributedEventHandler, ITransientDependency + { + protected IPermissionDefinitionManager PermissionDefinitionManager { get; } + protected IPermissionDataSeeder PermissionDataSeeder { get; } + + public PermissionTenantCreatedHandler(IPermissionDefinitionManager permissionDefinitionManager, IPermissionDataSeeder permissionDataSeeder) + { + PermissionDefinitionManager = permissionDefinitionManager; + PermissionDataSeeder = permissionDataSeeder; + } + + public async Task HandleEventAsync(TenantCreatedEto eventData) + { + var permissionNames = PermissionDefinitionManager + .GetPermissions() + .Where(p => p.MultiTenancySide.HasFlag(MultiTenancySides.Tenant)) + .Where(p => !p.Providers.Any() || p.Providers.Contains(RolePermissionValueProvider.ProviderName)) + .Select(p => p.Name) + .ToArray(); + + await PermissionDataSeeder.SeedAsync( + RolePermissionValueProvider.ProviderName, + "admin", + permissionNames, + eventData.Id + ); + } + } +} From 5809e343b46572e2ebdcca39d61fb54847777a6c Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 2 Feb 2021 11:36:07 +0300 Subject: [PATCH 19/28] add catch-all route for pages and do not handle root. --- .../src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs | 5 ++++- .../Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs index 7833e6aa3e..953102aa79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs @@ -55,12 +55,15 @@ namespace Volo.CmsKit.Public.Web { options.AddMaps(validate: true); }); + } + public override void PostConfigureServices(ServiceConfigurationContext context) + { Configure(options => { if (GlobalFeatureManager.Instance.IsEnabled()) { - options.Conventions.AddPageRoute("/CmsKit/Pages/Index", @"/{pageUrl}"); + options.Conventions.AddPageRoute("/CmsKit/Pages/Index", @"{*pageUrl:minlength(1)}"); } }); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml index c31edaaba8..73c7637b01 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml @@ -1,4 +1,4 @@ -@page "{pageUrl}" +@page "{*pageUrl}" @using Microsoft.AspNetCore.Mvc.Localization @using Volo.CmsKit.Localization @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages From 6413691c0e9fda04119c54f6efdf7424f2cd9d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 2 Feb 2021 15:13:25 +0300 Subject: [PATCH 20/28] Cancel event handlers in identity and permission modules. --- .../NullTenantDatabaseSchemaMigrator.cs | 13 ------- .../TenantDatabaseSchemaMigrator.cs | 13 ------- .../Abp/Identity/AbpIdentityDomainModule.cs | 15 -------- .../Volo/Abp/Identity/AbpIdentityOptions.cs | 5 --- .../Identity/IdentityTenantCreatedHandler.cs | 32 ---------------- .../AbpPermissionManagementDomainModule.cs | 18 +-------- .../PermissionManagementOptions.cs | 5 --- .../PermissionTenantCreatedHandler.cs | 38 ------------------- 8 files changed, 1 insertion(+), 138 deletions(-) delete mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs delete mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs delete mode 100644 modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs delete mode 100644 modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs deleted file mode 100644 index 7d5e76f11b..0000000000 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/NullTenantDatabaseSchemaMigrator.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.MultiTenancy -{ - public class NullTenantDatabaseSchemaMigrator : ITenantDatabaseSchemaMigrator, ISingletonDependency - { - public Task MigrateAsync() - { - return Task.CompletedTask; - } - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs deleted file mode 100644 index e6fef5c427..0000000000 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantDatabaseSchemaMigrator.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; - -namespace Volo.Abp.MultiTenancy -{ - public interface ITenantDatabaseSchemaMigrator - { - /// - /// Set Current Tenant before calling this method. - /// - /// - Task MigrateAsync(); - } -} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs index 6c2197b38d..4326d1aeb8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.Options; using Volo.Abp.AutoMapper; using Volo.Abp.Domain; using Volo.Abp.Domain.Entities.Events.Distributed; -using Volo.Abp.EventBus.Distributed; using Volo.Abp.Modularity; using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending.Modularity; @@ -59,20 +58,6 @@ namespace Volo.Abp.Identity }); context.Services.AddAbpDynamicOptions(); - - Configure(options => - { - var serviceProvider = context.Services.GetServiceProviderOrNull(); - if (serviceProvider != null) - { - var abpIdentityOptions = serviceProvider.GetRequiredService>().Value; - if (!abpIdentityOptions.IsDistributedEventHandlingEnabled) - { - var identityDomainAssembly = typeof(AbpIdentityDomainModule).Assembly; - options.Handlers.RemoveAll(x => x.Assembly == identityDomainAssembly); - } - } - }); } public override void PostConfigureServices(ServiceConfigurationContext context) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs index 36b7ba587a..6cfaf75c0c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptions.cs @@ -4,11 +4,6 @@ { public ExternalLoginProviderDictionary ExternalLoginProviders { get; } - /// - /// Default: true. - /// - public bool IsDistributedEventHandlingEnabled { get; } = true; - public AbpIdentityOptions() { ExternalLoginProviders = new ExternalLoginProviderDictionary(); diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs deleted file mode 100644 index 92a0be629c..0000000000 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityTenantCreatedHandler.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Threading.Tasks; -using AutoMapper.Internal; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Volo.Abp.DependencyInjection; -using Volo.Abp.EventBus.Distributed; -using Volo.Abp.MultiTenancy; - -namespace Volo.Abp.Identity -{ - public class IdentityTenantCreatedHandler : IDistributedEventHandler, ITransientDependency - { - public ILogger Logger { get; set; } - - protected IIdentityDataSeeder IdentityDataSeeder { get; } - - public IdentityTenantCreatedHandler(IIdentityDataSeeder identityDataSeeder) - { - IdentityDataSeeder = identityDataSeeder; - Logger = NullLogger.Instance; - } - - public async Task HandleEventAsync(TenantCreatedEto eventData) - { - await IdentityDataSeeder.SeedAsync( - eventData.Properties.GetOrDefault("AdminEmail") as string ?? "admin@abp.io", - eventData.Properties.GetOrDefault("AdminPassword") as string ?? "1q2w3E*", - eventData.Id - ); - } - } -} diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs index 5b3eb9f40f..f437802c6b 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainModule.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.Options; using Volo.Abp.Authorization; using Volo.Abp.Caching; using Volo.Abp.Domain; -using Volo.Abp.EventBus.Distributed; using Volo.Abp.Json; using Volo.Abp.Modularity; @@ -17,21 +16,6 @@ namespace Volo.Abp.PermissionManagement [DependsOn(typeof(AbpJsonModule))] public class AbpPermissionManagementDomainModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - var serviceProvider = context.Services.GetServiceProviderOrNull(); - if (serviceProvider != null) - { - var abpIdentityOptions = serviceProvider.GetRequiredService>().Value; - if (!abpIdentityOptions.IsDistributedEventHandlingEnabled) - { - var identityDomainAssembly = typeof(AbpPermissionManagementDomainModule).Assembly; - options.Handlers.RemoveAll(x => x.Assembly == identityDomainAssembly); - } - } - }); - } + } } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs index c36cde49ee..2e29ab9c29 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs @@ -9,11 +9,6 @@ namespace Volo.Abp.PermissionManagement public Dictionary ProviderPolicies { get; } - /// - /// Default: true. - /// - public bool IsDistributedEventHandlingEnabled { get; } = true; - public PermissionManagementOptions() { ManagementProviders = new TypeList(); diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs deleted file mode 100644 index 8962574434..0000000000 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionTenantCreatedHandler.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.DependencyInjection; -using Volo.Abp.EventBus.Distributed; -using Volo.Abp.MultiTenancy; - -namespace Volo.Abp.PermissionManagement -{ - public class PermissionTenantCreatedHandler : IDistributedEventHandler, ITransientDependency - { - protected IPermissionDefinitionManager PermissionDefinitionManager { get; } - protected IPermissionDataSeeder PermissionDataSeeder { get; } - - public PermissionTenantCreatedHandler(IPermissionDefinitionManager permissionDefinitionManager, IPermissionDataSeeder permissionDataSeeder) - { - PermissionDefinitionManager = permissionDefinitionManager; - PermissionDataSeeder = permissionDataSeeder; - } - - public async Task HandleEventAsync(TenantCreatedEto eventData) - { - var permissionNames = PermissionDefinitionManager - .GetPermissions() - .Where(p => p.MultiTenancySide.HasFlag(MultiTenancySides.Tenant)) - .Where(p => !p.Providers.Any() || p.Providers.Contains(RolePermissionValueProvider.ProviderName)) - .Select(p => p.Name) - .ToArray(); - - await PermissionDataSeeder.SeedAsync( - RolePermissionValueProvider.ProviderName, - "admin", - permissionNames, - eventData.Id - ); - } - } -} From f57c4c8b47f13dc3732c79bf64c81262208ed6ce Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Feb 2021 20:41:14 +0800 Subject: [PATCH 21/28] Add data-datepicker attribute to ignore initialize Datepickers. Resolve #7571 --- .../bootstrap/dom-event-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index 431d9093f7..a4e7405385 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -159,7 +159,7 @@ abp.dom.initializers.initializeDatepickers = function ($rootElement) { $rootElement - .findWithSelf('input.datepicker,input[type=date]') + .findWithSelf('input.datepicker,input[type=date][data-datepicker!=false]') .each(function () { var $input = $(this); $input From 1b6b6c6758555b40015f874aaa088b073e830233 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Feb 2021 20:44:54 +0800 Subject: [PATCH 22/28] Rename data-datepicker to abp-data-datepicker. --- .../bootstrap/dom-event-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index a4e7405385..55c604cf4a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -159,7 +159,7 @@ abp.dom.initializers.initializeDatepickers = function ($rootElement) { $rootElement - .findWithSelf('input.datepicker,input[type=date][data-datepicker!=false]') + .findWithSelf('input.datepicker,input[type=date][abp-data-datepicker!=false]') .each(function () { var $input = $(this); $input From f5fadcb41057f0486d4712a89d6e4bcb8e528346 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 2 Feb 2021 15:56:02 +0300 Subject: [PATCH 23/28] fix ng-bootstrap modal closing problem --- .../theme-shared/src/lib/components/modal/modal.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts index 0142adeb25..c5829c8e79 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts @@ -154,6 +154,7 @@ export class ModalComponent implements OnDestroy { } ngOnDestroy(): void { + this.toggle(false); this.destroy$.next(); } From 89a3d558a2c06a914ca2655f340c4b0f50b0dd8f Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 2 Feb 2021 15:56:09 +0300 Subject: [PATCH 24/28] update yarn.lock --- npm/ng-packs/yarn.lock | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/npm/ng-packs/yarn.lock b/npm/ng-packs/yarn.lock index c87d4f36e2..bae49929de 100644 --- a/npm/ng-packs/yarn.lock +++ b/npm/ng-packs/yarn.lock @@ -2,12 +2,12 @@ # yarn lockfile v1 -"@abp/ng.core@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.core/-/ng.core-4.2.0-rc.2.tgz#d5ae888cd6beba0ab7cc92a9759e8f3b4095f5dc" - integrity sha512-uPsxulybSdGyBpR08d9XR3i/YdG/ILvo1Gzyz2wTOG/gay12hh/p83S50kWeBuPkh8uOiT3ezO9BY/GPVrRI+Q== +"@abp/ng.core@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.core/-/ng.core-4.2.0.tgz#cd6848291699b9bc60303c58162074d80a0c4428" + integrity sha512-HhTpOeK5RdzlfK5zy5t7v68DDqNqAB75if6E4Lt2CwgY8pQUuY0EIzD0+AXhkC5+bjyULNHV2/HW3q/Fm75TVg== dependencies: - "@abp/utils" "^4.2.0-rc.1" + "@abp/utils" "^4.2.0-rc.2" "@angular/localize" "~10.0.10" "@ngxs/store" "^3.7.0" angular-oauth2-oidc "^10.0.0" @@ -17,35 +17,35 @@ ts-toolbelt "6.15.4" tslib "^2.0.0" -"@abp/ng.feature-management@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.feature-management/-/ng.feature-management-4.2.0-rc.2.tgz#c0273a07f73d95e7133ec90c1facd5de51121430" - integrity sha512-sGQfh0plQGtm3qCGYs1qmCtWt2EOwVgRyUcNd2ipzorH55S5/dX7or9dYKZofPz7GF55FohbfpxBqnKnBo0WOQ== +"@abp/ng.feature-management@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.feature-management/-/ng.feature-management-4.2.0.tgz#2c89d64845533c23560325f806289c131457ced9" + integrity sha512-IftgAecb2bygNQhMCvQ6m6BxTq7eAvKE36jBZ1s72S658PtO9xx1LIjCql/QNKyu8YpI88Uc5OXZM8mJOVsYuw== dependencies: - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.identity@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.identity/-/ng.identity-4.2.0-rc.2.tgz#fe20f05b60980561218f8357df55c00d85af8eb2" - integrity sha512-zrY5oPhDq8lPcvDvxYM/hS5CtRj71Zlu04Slz4f+ljlStWHBOBZx1VVBl4OQvbDGxDGC04Pf2Sj3PtppEU28gw== +"@abp/ng.identity@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.identity/-/ng.identity-4.2.0.tgz#e6e321545a612b37f7f1ff8d0df43086319e77fa" + integrity sha512-yNSxscWa9Po9H+7b7m94oAzMNLe360yJq9s/yw2EhEnkUTJ5bBbbrnSKK35NNRhziYp9V5CwYsW7uhjxQ3NGqQ== dependencies: - "@abp/ng.permission-management" "~4.2.0-rc.2" - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.permission-management" "~4.2.0" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.permission-management@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.permission-management/-/ng.permission-management-4.2.0-rc.2.tgz#771285283bf3c82dcdd6a07ef444ada73b918d4a" - integrity sha512-FSMSiXGhalTMZIJzQCS6fYRdFH2eVmk73aPeFn1NnMxNdhzCXfbsHpX/lVes+UMw7CddEEgriv0GQYi8dYMnDw== +"@abp/ng.permission-management@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.permission-management/-/ng.permission-management-4.2.0.tgz#ad2970796b8b1aecfcd5b0a0136c508a0e18e9d4" + integrity sha512-wG26+7clnqll7d2+Uypd4xleA2DjpSkkctMOGai7EDaHqgVFDjfX3lZHtz/u7Xt9y9wHltGhqONjh/FuRkrgBA== dependencies: - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.schematics@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.schematics/-/ng.schematics-4.2.0-rc.2.tgz#93774148f57964c72498fa060c04eb99f6c3987d" - integrity sha512-Ul/+nPTnGpNhi0NMfeYY9fDnsTVzVxP4iSIdqXevPxugeY6pqCefC84i0XHdkVsxIi1UR7VP84tqE9SCv7KnCw== +"@abp/ng.schematics@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.schematics/-/ng.schematics-4.2.0.tgz#db1a8ae787cf028452774a51cb62e784a1670e25" + integrity sha512-44bDoLRqDzcJ/X75KH1O0AoQev7zKh0IkAe4N7KQNgjgRiIuWe3h/SQPfqTSlZNT2ZYo/SZMZyX5Nv8OSKXydg== dependencies: "@angular-devkit/core" "~11.0.2" "@angular-devkit/schematics" "~11.0.2" @@ -53,37 +53,37 @@ jsonc-parser "^2.3.0" typescript "~3.9.2" -"@abp/ng.setting-management@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.setting-management/-/ng.setting-management-4.2.0-rc.2.tgz#a7c5bb30e881f8efe702fcc8f3b95bf442b0289a" - integrity sha512-5sOk19EzFBIIdeTAx6EEmgh2pYOj5oRXq6uuAOmGVzZiX7arFoyqvTR4OAypIBQdMlZ0Iv4EApvJLD6/1IIrqw== +"@abp/ng.setting-management@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.setting-management/-/ng.setting-management-4.2.0.tgz#4a4b685ee74ac5030b7e9e73ee67110219df9065" + integrity sha512-Ldl+I2jWgMuQdMOnnOBIfk0OoTao5QN9zzQwCGMPgu7dOGjD8IT9h9CpkG4ROKw9YAT1R+P8QlQ6502jQWOMYQ== dependencies: - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.tenant-management@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.tenant-management/-/ng.tenant-management-4.2.0-rc.2.tgz#dc5c019f16ac679589dbeac85317628ec6682096" - integrity sha512-O2Lb0Fe+L11yC69DAcgX4hY6KwI9ojaDnPTFxGtvvTjaUVKnxxchQrJwP0ITsudZe5cWKbF7cME3b3uH4jorBA== +"@abp/ng.tenant-management@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.tenant-management/-/ng.tenant-management-4.2.0.tgz#e42aa4b81036c653abcc0144b74c287587a4ec9f" + integrity sha512-EWfwKAH4wjA37xigikXzI+jTNGopV3WEP/ezQj1KO7pbW1peiTXwIPHN7GDc8MJ6f2olZki7kXypzmgJn9A6KQ== dependencies: - "@abp/ng.feature-management" "~4.2.0-rc.2" - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.feature-management" "~4.2.0" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.theme.basic@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.theme.basic/-/ng.theme.basic-4.2.0-rc.2.tgz#83c6ae4d0d95fc0271386a02c2f22531325c3b26" - integrity sha512-VGEDWIIRnmHPrhcjIhhBcqILI8NUsuVIX7K5XfJUuf3WmEzH9Ru9Yyi81AYZNuBNXNAjyjRH/nIxwljnHxO8bA== +"@abp/ng.theme.basic@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.theme.basic/-/ng.theme.basic-4.2.0.tgz#bc239a9c014cca926c80196eb751a40ceeb7446c" + integrity sha512-xTy/AjuPujVNVb/cUenwRiKAS/BoYRR2Hh+AMksfgndIPMUEXYtJ8eSG+XOAtu0+QE/QI5RYk7FzcbfxDBeuvQ== dependencies: - "@abp/ng.theme.shared" "~4.2.0-rc.2" + "@abp/ng.theme.shared" "~4.2.0" tslib "^2.0.0" -"@abp/ng.theme.shared@~4.2.0-rc.2": - version "4.2.0-rc.2" - resolved "https://registry.yarnpkg.com/@abp/ng.theme.shared/-/ng.theme.shared-4.2.0-rc.2.tgz#935ca3aa32d8ced85d277139ce790f3cc3faa184" - integrity sha512-UjYPd6KL3bO9PN9XEmBlKQSc0C3EJsLHhifoV+rgtqAHvortOygSHHknOthRA4PN+cg2/PiuWA5gpvMHP1K7Ow== +"@abp/ng.theme.shared@~4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/ng.theme.shared/-/ng.theme.shared-4.2.0.tgz#4b7925c61224d4d1b182c50e11ef915b50b78dda" + integrity sha512-LfatA+lk/Wn6MOAZlHlJIiTH5uxqRWBl4QyWXhFrXhYYpJG4je06Y9KA3h+BP4dIQIe06gwAVYpE7D/ur3CbEQ== dependencies: - "@abp/ng.core" "~4.2.0-rc.2" + "@abp/ng.core" "~4.2.0" "@fortawesome/fontawesome-free" "^5.14.0" "@ng-bootstrap/ng-bootstrap" "^7.0.0" "@ngx-validate/core" "^0.0.13" @@ -92,10 +92,10 @@ chart.js "^2.9.3" tslib "^2.0.0" -"@abp/utils@^4.2.0-rc.1": - version "4.2.0-rc.1" - resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.2.0-rc.1.tgz#397615ec208150f46ae626b67ea71053750f612f" - integrity sha512-MkXq5pKf/ZzJJT9oHYgBlUOL5wTx03qdxJeD82nxwJx6w5JFdshBWKj5iJixE1aM5HnzwSGn7bxFqe5QOKST+Q== +"@abp/utils@^4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.2.0.tgz#073330e3e3f6ee61892f50260e48dbe1b05df35e" + integrity sha512-75qR3SdiAa75wqleAx9sUMXLj4m9duuBo5+2sVv7Y29GcEyKUPvm8B1s6tksvSGA0e3vnFTHeVEc10eD1xKHSQ== dependencies: just-compare "^1.3.0" From cea97c23191abd4e40a3ed526b6fe073e1850ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 2 Feb 2021 16:00:04 +0300 Subject: [PATCH 25/28] Create TenantConnectionStringUpdatedEto.cs --- .../TenantConnectionStringUpdatedEto.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs new file mode 100644 index 0000000000..022343821b --- /dev/null +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs @@ -0,0 +1,21 @@ +using System; +using Volo.Abp.Domain.Entities.Events.Distributed; +using Volo.Abp.EventBus; + +namespace Volo.Abp.MultiTenancy +{ + [Serializable] + [EventName("abp.multi_tenancy.tenant.connection_string.updated")] + public class TenantConnectionStringUpdatedEto : EtoBase + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public string ConnectionStringName { get; set; } + + public string OldValue { get; set; } + + public string NewValue { get; set; } + } +} From 183b4a7058dfb70f7e48007707e6ef68dde27d09 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 2 Feb 2021 17:40:01 +0300 Subject: [PATCH 26/28] Permission service should filter granted policies from list of policy resolve #7572 --- .../core/src/lib/services/permission.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts index c549c5a7a8..af6a8e3d46 100644 --- a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts @@ -19,6 +19,17 @@ export class PermissionService { return this.isPolicyGranted(key, policies); } + filterGrantedPolicies(policyKeys: Array) { + const policies = this.getSnapshot(); + return policyKeys.filter(key => this.isPolicyGranted(key, policies)); + } + + filterGrantedPolicies$(policyKeys: Array) { + return this.getStream().pipe( + map(policies => policyKeys.filter(key => this.isPolicyGranted(key, policies))), + ); + } + protected isPolicyGranted(key: string, grantedPolicies: Record) { if (!key) return true; From 143a9788c737fd2c0c82481dde535ad01640625f Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 2 Feb 2021 18:55:35 +0300 Subject: [PATCH 27/28] filter fn modified to filter given items by policy --- .../packages/core/src/lib/models/common.ts | 4 ++++ .../core/src/lib/services/permission.service.ts | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index d4d44faae0..db03b1cea7 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -12,6 +12,10 @@ export namespace ABP { sendNullsAsQueryParam?: boolean; } + export interface HasPolicy { + requiredPolicy?: string; + } + export interface Test extends Partial { baseHref?: string; listQueryDebounceTime?: number; diff --git a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts index af6a8e3d46..b47c29ed61 100644 --- a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts @@ -3,6 +3,7 @@ import { map } from 'rxjs/operators'; import snq from 'snq'; import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models'; import { ConfigStateService } from './config-state.service'; +import { ABP } from '../models'; @Injectable({ providedIn: 'root' }) export class PermissionService { @@ -19,14 +20,20 @@ export class PermissionService { return this.isPolicyGranted(key, policies); } - filterGrantedPolicies(policyKeys: Array) { + filterItemsByPolicy(items: Array) { const policies = this.getSnapshot(); - return policyKeys.filter(key => this.isPolicyGranted(key, policies)); + return items.filter( + item => !item.requiredPolicy || this.isPolicyGranted(item.requiredPolicy, policies), + ); } - filterGrantedPolicies$(policyKeys: Array) { + filterItemsByPolicy$(items: Array) { return this.getStream().pipe( - map(policies => policyKeys.filter(key => this.isPolicyGranted(key, policies))), + map(policies => + items.filter( + item => !item.requiredPolicy || this.isPolicyGranted(item.requiredPolicy, policies), + ), + ), ); } From 8c70f3593033c85592a7ec33d73c0babf4eabeed Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 2 Feb 2021 19:02:58 +0300 Subject: [PATCH 28/28] import changed --- .../packages/core/src/lib/services/permission.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts index b47c29ed61..eb6b3fc75e 100644 --- a/npm/ng-packs/packages/core/src/lib/services/permission.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/permission.service.ts @@ -3,7 +3,7 @@ import { map } from 'rxjs/operators'; import snq from 'snq'; import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models'; import { ConfigStateService } from './config-state.service'; -import { ABP } from '../models'; +import { ABP } from '../models/common'; @Injectable({ providedIn: 'root' }) export class PermissionService {