diff --git a/.gitignore b/.gitignore index 3c5c4f89da..2f820efc4d 100644 --- a/.gitignore +++ b/.gitignore @@ -310,4 +310,7 @@ abp-build-config.json /templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Test/ # Identity Server temp signature file -tempkey.jwk \ No newline at end of file +tempkey.jwk + +# ABP Analyzing files +*.abppkg.analyze.json \ No newline at end of file diff --git a/docs/en/Blog-Posts/2021-04-05 CmsKit/POST.md b/docs/en/Blog-Posts/2021-04-05 CmsKit/POST.md index ad8b89faa0..740adb96c7 100644 --- a/docs/en/Blog-Posts/2021-04-05 CmsKit/POST.md +++ b/docs/en/Blog-Posts/2021-04-05 CmsKit/POST.md @@ -1,3 +1,85 @@ -# Introducing the CMS Kit Module for the ABP Framework +# Introducing The CMS-Kit Module + +One of the most exciting announcements of the ABP Framework 4.3 release was releasing the initial version of the CMS Kit module. The team had been working hard to release the initial version for months. For those who didn't read the [ABP Framework 4.3 release post](https://blog.abp.io/abp/ABP-Framework-4.3-RC-Has-Been-Published), the CMS Kit module adds CMS(Content Management System) capabilities to your application. Some of the CMS Kit features are open source and free, while others are only included in the Pro version included in the ABP Commercial. + +List of free and pro features in the CMS Kit module; + +- Free + - Page System: Provides a **page** management system to manage dynamic pages. + - Blog System: Provides a **blog** system to create blogs and publish posts. + - Tag System: Provides a **tag** system to tag any kind of resources, such as blog posts. + - Comment System: Provides a **comment** system to add comments feature to any type of resource, such as blog posts, products, etc. + - Reaction System: Provides a **reaction** system to add reactions to any type of resource, such as blog posts or comments, etc. + - Rating System: Provides a **rating** system to add ratings feature to any type of resource, such as comments, products, etc. +- Pro + - Newsletter System: Provides a **newsletter** system to allow users to subscribe to newsletters. + - Contact Form System: Provides a **contact form** system to allow users to write a message to you on public websites. + +## Installation + +CMS Kit module comes installed with commercial templates when you create the solution with the public website option. You can run the following command and create a solution with a public website. + +```bash +abp new Acme --with-public-website +``` + +If you're using the open-source version or adding the module to an existing project, the ABP CLI allows adding a module to a solution using `add-module` command. + +You can run the following command to add the module to an open-source solution. + +```bash +abp add-module Volo.CmsKit +``` + +If you're a commercial user, run the following command to install the pro version of the module. + +```bash +abp add-module Volo.CmsKit.Pro +``` + +After adding the module to the solution, you need to configure features. The CMS Kit module uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all features. To enable the features in the CMS Kit module, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure` method to enable all features in the CMS kit module. + + ```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.EnableAll(); +}); + ``` + +If you're a commercial user, you need to enable CMS Kit Pro features as well. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKitPro(cmsKitPro => +{ + cmsKitPro.EnableAll(); +}); +``` + +> If you are using Entity Framework Core, do not forget to add a new migration and update your database after configuring the features. + +We've completed the installation step. Run the project, and you will see the CMS menu item in the menu. + +![cms-kit-menu](cms-kit-menu.png) + +> CMS Kit's initial release only supports the MVC UI. We're planning to add Angular and Blazor support in upcoming releases. + +## Package Structures + +CMS Kit is designed for various usage scenarios. When you visit [nuget.org](https://www.nuget.org/packages?q=Volo.CmsKit) or [abp.io](https://abp.io/packages?moduleName=Volo.CmsKit.Pro) to see the available CMS Kit packages, you will find out that packages have admin, public and unified versions. + +For example, + + - `Volo.CmsKit.Admin.Application`: Contains functionality required by admin websites. + - `Volo.CmsKit.Public.Application`: Contains functionality required by public websites. + - `Volo.CmsKit.Application` : Unified package dependent on both public and admin packages. + + If you want to separate admin and public website codes, you can use the admin and public packages. However, if you want to keep admin and public website codes in a shared project, you can use the unified packages to include admin and public packages. + +> It is recommended to use the unified packages instead of adding both admin and public packages. + + + +We've covered the initial features, installation and configuration steps in this post. You can read the [open-source](https://docs.abp.io/en/abp/latest/Modules/Cms-Kit) and [commercial](https://docs.abp.io/en/commercial/latest/modules/CMS-Kit) documentation to get further information about features and the CMS Kit module. CMS Kit's initial version contains lots of features that you can easily integrate and use in your applications. We're planning to improve the existing features, fixing bugs and adding new features in upcoming releases. If you want to give some feedback or have a feature request, please reach out to us from [GitHub](https://github.com/abpframework/abp) or [support.abp.io](https://support.abp.io). We will be happy to plan the CMS Kit module's future together. + +Thank you! -TODO... \ No newline at end of file diff --git a/docs/en/Blog-Posts/2021-04-05 CmsKit/cms-kit-menu.png b/docs/en/Blog-Posts/2021-04-05 CmsKit/cms-kit-menu.png new file mode 100644 index 0000000000..3f187c9a9d Binary files /dev/null and b/docs/en/Blog-Posts/2021-04-05 CmsKit/cms-kit-menu.png differ diff --git a/docs/en/Community-Articles/2021-03-12-Simple-SignalR-Notification/POST.md b/docs/en/Community-Articles/2021-03-12-Simple-SignalR-Notification/POST.md index 7a88adde44..8aeff16612 100644 --- a/docs/en/Community-Articles/2021-03-12-Simple-SignalR-Notification/POST.md +++ b/docs/en/Community-Articles/2021-03-12-Simple-SignalR-Notification/POST.md @@ -38,8 +38,19 @@ Open `YourProjectWebModule.cs` class and add the following line to the `PreConfi #### 2- Add Client Scripts -2- In the `ConfigureServices` method of your web module add the following code to add the `signalr.js` and `notification-hub.js`. We'll add these packages in the next steps. +2- In the `ConfigureServices` method of your web module add the following code to add the `signalr.js` and `notification-hub.js`. We'll add these packages in the next steps. If you are not using Lepton Theme you can add the files to `StandardBundles.Scripts.Global`. +```csharp + Configure(options => + { + options + .ScriptBundles + .Get(LeptonThemeBundles.Scripts.Global) //or -> Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling.StandardBundles.Scripts.Global + .AddFiles("/libs/signalr/signalr.js") + .AddFiles("/Pages/notification-hub.js"); + }); + ``` + ![Script Bundles](add-script-bundles.jpg) #### 3- Add Hub Endpoint @@ -71,6 +82,11 @@ Add the following JavaScript class into your `Pages` folder in your Web project. Add [Microsoft.SignalR](https://www.npmjs.com/package/@microsoft/signalr) JavaScript package to the `package.json` which is located in your root folder of the Web project. After you add it, run `yarn` command in your Web directory to be able to install this package. +You can install the latest version (3.1.13 will be old) +``` + "@microsoft/signalr": "^3.1.13" +```` + ![Add SignalR package](signalr-package.jpg) #### 3- Add resource Mapping @@ -94,6 +110,8 @@ To do this replace the `Index.cshtml` and `Index.cshtml.cs` with the followings: #### 5- See it in action -Run your web project and in the Index page you'll see a button named as "Get Notification". Click the button and see the notification that comes from SignalR. This is a basic usage of SignalR notification system. You can implement it according to your own requirements. +Run your web project and in the Index page you'll Server Time will be updated every second. The time information comes from backend via SignalR. +This is a very basic usage of SignalR notification system. +You can implement your own SignalR notification system based on your requirements. ![Result](result.jpg) diff --git a/docs/en/Entity-Framework-Core-Migrations.md b/docs/en/Entity-Framework-Core-Migrations.md index be5968a9af..4d42d8bb97 100644 --- a/docs/en/Entity-Framework-Core-Migrations.md +++ b/docs/en/Entity-Framework-Core-Migrations.md @@ -881,6 +881,67 @@ We had a reference to the `Acme.BookStore.EntityFrameworkCore.DbMigrationsForSec You can run the `.DbMigrator` application to migrate & seed the databases. To test, you can delete both databases and run the `.DbMigrator` application again to see if it creates both of the databases. +## Separating Host & Tenant Database Schemas + +In a multi-tenant solution, you may want to separate your database schemas, so host-related tables don't locate in the tenant databases when tenants have separate databases. + +Some pre-built ABP modules are related only with the host side, like the [Tenant Management](Modules/Tenant-Management.md) module. So, in the tenant `DbContext` class you don't call `modelBuilder.ConfigureTenantManagement()` and that's all. + +However, some modules, like the [Identity](Modules/Identity.md) module, is both used in host and tenant sides. It stores tenant users in the tenant database and host users in the host database. However, it stores some entities, like `IdentityClaimType`, only in the host side. In this case, you don't want to add these tables in the tenant database, even if they are not used and will always be empty. + +ABP provides a simple way to set the multi-tenancy side for a `DbContext`, so the modules can check it and decide to map tables to the database, or not. + +````csharp +public class MyTenantDbContext : AbpDbContext +{ + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.SetMultiTenancySide(MultiTenancySides.Tenant); + + base.OnModelCreating(modelBuilder); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureAuditLogging(); + } +} +```` + +The first line in the `OnModelCreating` sets multi-tenancy side to `Tenant`. For this example, Feature management tables are not created (because all the tables are host-specific), so calling `modelBuilder.ConfigureFeatureManagement()` has no effect. Also, `ConfigureIdentity()` call respects to the multi-tenancy side and doesn't create host-specific tables for this database. + +`SetMultiTenancySide` can get the following values: + +* `MultiTenancySides.Both` (**default value**): This `DbContext` (and the related database) is shared by host and tenant. +* `MultiTenancySides.Host`: This `DbContext` (and the related database) is used only by the host side. +* `MultiTenancySides.Tenant`: This `DbContext` (and the related database) is only for tenants. + +If you create a re-usable application module or want to check that value in your application code, you can use `modelBuilder.GetMultiTenancySide()` to check the current side. + +````csharp +var side = modelBuilder.GetMultiTenancySide(); +if (!side.HasFlag(MultiTenancySides.Host)) +{ + ... +} +```` + +Or practically you can use one of the shortcut extension methods: + +````csharp +if (modelBuilder.IsTenantOnlyDatabase()) +{ + ... +} +```` + +There are four methods to check the current side: + +* `IsHostDatabase()`: Returns `true` if you should create host-related tables. It is equivalent of checking `modelBuilder.GetMultiTenancySide().HasFlag(MultiTenancySides.Host)`. +* `IsHostOnlyDatabase()`: Returns `true` if you should only create host-related tables, but should not create tenant-related tables. It is equivalent of checking `modelBuilder.GetMultiTenancySide() == MultiTenancySides.Host`. +* `IsTenantDatabase()`: Returns `true` if you should create tenant-related tables. It is equivalent of checking `modelBuilder.GetMultiTenancySide().HasFlag(MultiTenancySides.Tenant)`. +* `IsTenantOnlyDatabase()`: Returns `true` if you should only create tenant-related tables, but should not create host-related tables. It is equivalent of checking `modelBuilder.GetMultiTenancySide() == MultiTenancySides.Tenant`. + +All pre-built ABP [modules](Modules/Index.md) checks this value in their `modelBuilder.ConfigureXXX()` methods. + ## Conclusion This document explains how to split your databases and manage your database migrations of your solution for Entity Framework Core. In brief, you need to have a separate migration project per different databases. diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index a2c0e79996..241a08790f 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -626,6 +626,24 @@ See the "*ConfigureByConvention Method*" section above for more information. ## Advanced Topics +### Controlling the Multi-Tenancy + +If your solution is [multi-tenant](Multi-Tenancy.md), tenants may have **separate databases**, you have **multiple** `DbContext` classes in your solution and some of your `DbContext` classes should be usable **only from the host side**, it is suggested to add `[IgnoreMultiTenancy]` attribute on your `DbContext` class. In this case, ABP guarantees that the related `DbContext` always uses the host [connection string](Connection-Strings.md), even if you are in a tenant context. + +**Example:** + +````csharp +[IgnoreMultiTenancy] +public class MyDbContext : AbpDbContext +{ + ... +} +```` + +Do not use the `[IgnoreMultiTenancy]` attribute if any one of your entities in your `DbContext` can be persisted in a tenant database. + +> When you use repositories, ABP already uses the host database for the entities don't implement the `IMultiTenant` interface. So, most of time you don't need to `[IgnoreMultiTenancy]` attribute if you are using the repositories to work with the database. + ### Set Default Repository Classes Default generic repositories are implemented by `EfCoreRepository` class by default. You can create your own implementation and use it for all the default repository implementations. @@ -782,4 +800,4 @@ public class MyCustomEfCoreBulkOperationProvider ## See Also * [Entities](Entities.md) -* [Repositories](Repositories.md) +* [Repositories](Repositories.md) \ No newline at end of file diff --git a/docs/en/Features.md b/docs/en/Features.md index b185eb2d74..3b1869a9a5 100644 --- a/docs/en/Features.md +++ b/docs/en/Features.md @@ -146,9 +146,9 @@ A feature should be defined to be able to check it. ### FeatureDefinitionProvider -Create a class inheriting the `FeatureDefinitionProvider` to define permissions. +Create a class inheriting the `FeatureDefinitionProvider` to define features. -**Example: Defining permissions** +**Example: Defining features** ```csharp using Volo.Abp.Features; diff --git a/docs/en/Modules/Cms-Kit.md b/docs/en/Modules/Cms-Kit.md index e13f1e585b..db35912ae6 100644 --- a/docs/en/Modules/Cms-Kit.md +++ b/docs/en/Modules/Cms-Kit.md @@ -1,3 +1,159 @@ # CMS Kit Module -TODO \ No newline at end of file +This module provides CMS(Content Management System) capabilities for your application. + +* Provides a **page** management system to manage dynamic pages. +* Provides a **blog** system to create blogs and publish posts. +* Provides a [**tag**](cms-kit/Tag-Management.md) system to tag any kind of resources, like blog posts. +* Provides a [**comment**](cms-kit/Comment-System.md) system to add comments feature to any kind of resource, like blog posts, products, etc. +* Provides a [**reaction**](cms-kit/Reaction-System.md) system to add reactions feature to any kind of resource, like blog posts or comments. +* Provides a [**rating**](cms-kit/Rating-System.md) system to add rating feature to any kind of resource. + +## How to install + +The ABP CLI allows adding a module to a solution using `add-module` command. CMS kit module can be added using the command below; + +```bash +abp add-module Volo.CmsKit +``` +Open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure` method to enable all features in the CMS kit module. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.EnableAll(); +}); + +``` + +> If you are using EntityFrameworkCore, do not forget to add a new migration and update your database. + +## Packages + +This module follows the [module development best practices guide](https://docs.abp.io/en/abp/latest/Best-Practices/Index) and consists of several NuGet and NPM packages. See the guide if you want to understand the packages and relations between them. + +CMS kit packages are designed for various usage scenarios. When you visit the [CMS kit package list page](https://www.nuget.org/packages?q=Volo.CmsKit), you will see that packages have admin, public and unified versions. +For example, + - `Volo.CmsKit.Admin.Application`: Contains functionality required by admin websites. + - `Volo.CmsKit.Public.Application`: Contains functionality required by public websites. + - `Volo.CmsKit.Application` : Unified package dependent on both public and admin packages. + +If you want to separate admin and public website codes, you can use the admin and public packages. However, if you want to keep admin and public website codes in a shared project, you can use the unified packages to include admin and public packages. + +It is recommended to use the unified packages instead of adding both admin and public packages. + +## Feature System + +CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. You can use the global feature system to enable all features or only enabled specific features easily. + +To enable all features in the CMS kit, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.EnableAll(); +}); +``` + +You can only enable specific features such as pages, like below. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.Pages.Enable(); +}); +``` + +## User interface + +### Menu items + +CMS kit module adds the following items to the "Main" menu, under the "CMS" menu item: + +* **Pages**: Page management page. +* **Blogs**: Blog management page. +* **Blog Posts**: Blog post management page. +* **Tags**: Tag management page. +* **Comments**: Comment management page. + +`CmsKitAdminMenus` class has the constants for the menu item names. + +### Pages + +### Page Management + +Pages page is used to manage dynamic pages in the system. + +![pages-page](../images/cmskit-module-pages-page.png) + +You can create or edit an existing page on this page. + +![pages-edit](../images/cmskit-module-pages-edit.png) + +* When you create a page, you can access the created page via `pages/{slug}` URL. + +### Blog Management + +Blogs page is used to create and manage blogs in your system. + +![blogs-page](../images/cmskit-module-blogs-page.png) + +A screenshot from the new blog creation modal: + +![blogs-edit](../images/cmskit-module-blogs-edit.png) + +#### Blog Features + +You can enable or disable a specific feature for blogs by clicking the features action. + +![blogs-feature-action](../images/cmskit-module-blogs-feature-action.png) + +You can select/deselect the desired features for blog posts. + +![features-dialog](../images/cmskit-module-features-dialog.png) + +### Blog Post Management + +When you create blogs, you can manage blog posts on this page. + +![blog-posts-page](../images/cmskit-module-blog-posts-page.png) + +You can create and edit an existing blog post on this page. If you enable specific features such as tags, you can set tags for the blog post on this page. + +![blog-post-edit](../images/cmskit-module-blog-post-edit.png) + +### Tag Management + +CMS Kit provides an extensible tagging mechanism to add tagging capabilities to various places. + +![tags-page](../images/cmskit-module-tags-page.png) + +You can create or edit an existing tag on this page. + +![tag-edit](../images/cmskit-module-tag-edit.png) + +### Comment Management + +CMS Kit provides an extensible commenting mechanism to add comments to various places. You can add comment control to anywhere you want and manage the comments. + +You can view and manage comments on this page. + +![comment-page](../images/cmskit-module-comment-page.png) + +You can manage and view replies on this page. + +![comments-detail](../images/cmskit-module-comments-detail.png) + +### Reactions + +CMS Kit provides an extensible reaction component system to allow users to send reactions to your content. Here how the reactions component looks on a sample page. + +![reactions](../images/cmskit-module-reactions.png) + +You can also customize the reaction icons shown in the reaction component. + +### Ratings + +You can use the rating component to add rating a mechanism to your content. Here how the rating component looks on a sample page. + +![ratings](../images/cmskit-module-ratings.png) diff --git a/docs/en/Modules/cms-kit/Comment-System.md b/docs/en/Modules/cms-kit/Comment-System.md new file mode 100644 index 0000000000..40b9d91a96 --- /dev/null +++ b/docs/en/Modules/cms-kit/Comment-System.md @@ -0,0 +1,117 @@ +# Comment System + +CMS kit provides a **rating** system to add comments feature to any kind of resource, like blog posts, products, etc. This section describes the details of the comments system. + +## Feature + +CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with public website option. If you're installing the CMS kit manually or want to enable the comment feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.Comments.Enable(); +}); +``` + +# Options + +## CmsKitCommentOptions + +You can use the comment system to add comments to any kind of resources, like blog posts, products etc. Comment system provides a mechanism to group comment definitions by entity types. For example, if you want to use comment system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product`, and add comments under these entity types. + +`CmsKitCommentOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example: + +```csharp +Configure(options => +{ + options.EntityTypes.Add(new CommentEntityTypeDefinition("Product")); +}); +``` + +> If you're using the blog feature, the ABP framework defines an entity type for the blog feature automatically. You can easily override or remove the predefined entity types in `Configure` method like shown above. + +`CmsKitCommentOptions` properties: + +- `EntityTypes`: List of defined entity types(`CmsKitCommentOptions`) in the comment system. + +`CommentEntityTypeDefinition` properties: + +- `EntityType`: Name of the entity type. + +# Internals + +## Domain Layer + +#### Aggregates + +This module follows the [Entity Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Entities) guide. + +##### Comment + +A comment represents a written comment from a user. + +- `Comment` (aggregate root): Represents a written comment in the system. + +#### Repositories + +This module follows the [Repository Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Repositories) guide. + +Following custom repositories are defined for this feature: + +- `ICommentRepository` + +#### Domain services + +This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide. + +##### Comment Manager + +`CommentManager` is used to perform some operations for the `Comment` aggregate root. + +### Application layer + +#### Application services + +- `CommentAdminAppService` (implements `ICommentAdminAppService`): Implements the use cases of comment management system, like listing or removing comments etc. +- `CommentPublicAppService` (implements `ICommentPublicAppService`): Implements the use cases of comment management on the public websites, like listing comments, adding comments etc. + +### Database providers + +#### Common + +##### Table / collection prefix & schema + +All tables/collections use the `Cms` prefix by default. Set static properties on the `CmsKitDbProperties` class if you need to change the table prefix or set a schema name (if supported by your database provider). + +##### Connection string + +This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. + +See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. + +#### Entity Framework Core + +##### Tables + +- CmsComments + +#### MongoDB + +##### Collections + +- **CmsComments** + +### MVC UI + +The comment system provides a commenting widget to allow users to send comments to resources on public websites. You can simply place the widget on a page like below. + +```csharp +@await Component.InvokeAsync(typeof(CommentingViewComponent), new +{ + entityType = "entityType", + entityId = "entityId" +}) +``` +You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the comments in the domain module. Entity ID represents the unique identifier for the resource that users send comments to, such as blog post ID or product ID. + +For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation. \ No newline at end of file diff --git a/docs/en/Modules/cms-kit/Rating-System.md b/docs/en/Modules/cms-kit/Rating-System.md new file mode 100644 index 0000000000..76aaaaa249 --- /dev/null +++ b/docs/en/Modules/cms-kit/Rating-System.md @@ -0,0 +1,116 @@ +# Rating System + +CMS kit provides a **rating** system to to add ratings feature to any kind of resource like blog posts, comments, etc. This section describes the details of the rating system. + +## Feature + +CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with the public website option. If you're installing the CMS kit manually or want to enable the rating feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.Ratings.Enable(); +}); +``` + +# Options + +## CmsKitRatingOptions + +You can use the rating system to to add ratings to any kind of resource, like blog posts, comments, etc. The rating system provides a mechanism to group ratings by entity types. For example, if you want to use the rating system for products, you need to define an entity type named `Product` and then add ratings under the defined entity type. + +`CmsKitRatingOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example: + +```csharp +Configure(options => +{ + options.EntityTypes.Add(new RatingEntityTypeDefinition("Product")); +}); +``` + +> If you're using the blog feature, the ABP framework defines an entity type for the blog feature automatically. You can easily override or remove the predefined entity types in `Configure` method like shown above. + +`CmsKitRatingOptions` properties: + +- `EntityTypes`: List of defined entity types(`RatingEntityTypeDefinition`) in the rating system. + +`RatingEntityTypeDefinition` properties: + +- `EntityType`: Name of the entity type. + +# Internals + +## Domain Layer + +#### Aggregates + +This module follows the [Entity Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Entities) guide. + +##### Rating + +A rating represents a given rating from a user. + +- `Rating` (aggregate root): Represents a given rating in the system. + +#### Repositories + +This module follows the [Repository Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Repositories) guide. + +Following custom repositories are defined for this feature: + +- `IRatingRepository` + +#### Domain services + +This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide. + +##### Reaction Manager + +`RatingManager` is used to perform some operations for the `Rating` aggregate root. + +### Application layer + +#### Application services + +- `RatingPublicAppService` (implements `IRatingPublicAppService`): Implements the use cases of rating system. + +### Database providers + +#### Common + +##### Table / collection prefix & schema + +All tables/collections use the `Cms` prefix by default. Set static properties on the `CmsKitDbProperties` class if you need to change the table prefix or set a schema name (if supported by your database provider). + +##### Connection string + +This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. + +See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. + +#### Entity Framework Core + +##### Tables + +- CmsRatings + +#### MongoDB + +##### Collections + +- **CmsRatings** + +### MVC UI + +The ratings system provides a rating widget to allow users send ratings to resources in public websites. You can simply place the widget on a page like below. + +```csharp +@await Component.InvokeAsync(typeof(RatingViewComponent), new +{ + entityType = "entityType", + entityId = "entityId" +}) +``` +You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the reactions in the domain module. Entity ID represents the unique identifier for the resource that users give ratings to, such as blog post ID or product ID. + +For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation. \ No newline at end of file diff --git a/docs/en/Modules/cms-kit/Reaction-System.md b/docs/en/Modules/cms-kit/Reaction-System.md new file mode 100644 index 0000000000..e1219e24c3 --- /dev/null +++ b/docs/en/Modules/cms-kit/Reaction-System.md @@ -0,0 +1,128 @@ +# Reaction System + +CMS kit provides a **reaction** system to add reactions feature to any kind of resource, like blog posts or comments. This section describes the details of the reaction system. + +## Feature + +CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with the public website option. If you're installing the CMS kit manually or want to enable reaction feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.Reactions.Enable(); +}); +``` + +# Options + +## CmsKitReactionOptions + +You can use the reaction system to to add reactions feature to any kind of resource, like blog posts or comments, etc. The reaction system provides a mechanism to group reactions by entity types. For example, if you want to use the reaction system for products, you need to define an entity type named `Product`, and then add reactions under the defined entity type. + +`CmsKitReactionOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example: + +```csharp +Configure(options => +{ + options.EntityTypes.Add( + new ReactionEntityTypeDefinition( + "Product", + reactions: new[] + { + new ReactionDefinition(StandardReactions.Smile), + new ReactionDefinition(StandardReactions.ThumbsUp), + new ReactionDefinition(StandardReactions.ThumbsDown), + new ReactionDefinition(StandardReactions.Confused), + new ReactionDefinition(StandardReactions.Eyes), + new ReactionDefinition(StandardReactions.Heart) + })); +}); +``` + +> If you're using the comment or blog features, the ABP framework defines predefined reactions for these features automatically. You can easily override or remove the predefined reactions in `Configure` method like shown above. + +`CmsKitReactionOptions` properties: + +- `EntityTypes`: List of defined entity types(`CmsKitReactionOptions`) in the reaction system. + +`ReactionEntityTypeDefinition` properties:asdas + +- `EntityType`: Name of the entity type. +- `Reactions`: List of defined reactions(`ReactionDefinition`) in the entity type. + +# Internals + +## Domain Layer + +#### Aggregates + +This module follows the [Entity Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Entities) guide. + +##### UserReaction + +A user reaction represents a given reaction from a user. + +- `UserReaction` (aggregate root): Represents a given reaction in the system. + +#### Repositories + +This module follows the [Repository Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Repositories) guide. + +Following custom repositories are defined for this feature: + +- `IUserReactionRepository` + +#### Domain services + +This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide. + +##### Reaction Manager + +`ReactionManager` is used to perform some operations for the `UserReaction` aggregate root. + +### Application layer + +#### Application services + +- `ReactionPublicAppService` (implements `IReactionPublicAppService`): Implements the use cases of reaction system. + +### Database providers + +#### Common + +##### Table / collection prefix & schema + +All tables/collections use the `Cms` prefix by default. Set static properties on the `CmsKitDbProperties` class if you need to change the table prefix or set a schema name (if supported by your database provider). + +##### Connection string + +This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. + +See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. + +#### Entity Framework Core + +##### Tables + +- CmsUserReactions + +#### MongoDB + +##### Collections + +- **CmsUserReactions** + +### MVC UI + +The reaction system provides a reaction widget to allow users to send reactions to resources on public websites. You can place the widget on a page like below. + +```csharp +@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new +{ + entityType = "entityType", + entityId = "entityId" +}) +``` +You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the reactions in the domain module. Entity ID represents the unique identifier for the resource that users give reactions to, such as blog post ID or product ID. + +For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation. \ No newline at end of file diff --git a/docs/en/Modules/cms-kit/Tag-Management.md b/docs/en/Modules/cms-kit/Tag-Management.md new file mode 100644 index 0000000000..aa4b675dac --- /dev/null +++ b/docs/en/Modules/cms-kit/Tag-Management.md @@ -0,0 +1,135 @@ +# Tag Management + +CMS kit provides a **tag** system to tag any kind of resources, like blog posts. This section describes the details of the tag system. + +## Feature + +CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with public website option. If you're installing the CMS kit manually or want to enable the tag management feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method. + +```csharp +GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => +{ + cmsKit.Tags.Enable(); +}); +``` + +# Options + +## CmsKitTagOptions + +You can use the tag system to tag any kind of resources, like blog posts, products, etc. The tag system provides a mechanism to group tags by entity types. For example, if you want to use the tag system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product` and add tags under these entity types. + +`CmsKitTagOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example: + +```csharp +Configure(options => +{ + options.EntityTypes.Add(new TagEntityTypeDefiniton("Product")); +}); +``` + +> If you're using the blog feature, the ABP framework defines an entity type for the blog feature automatically. You can easily override or remove the predefined entity types in `Configure` method like shown above. + +`CmsKitTagOptions` properties: + +- `EntityTypes`: List of defined entity types(`TagEntityTypeDefiniton`) in the tag system. + +`TagEntityTypeDefiniton` properties: + +- `EntityType`: Name of the entity type. +- `DisplayName`: Display name of the entity type. You can use a user friendly display name to show entity type definition on the admin website. +- `CreatePolicies`: List of policy names allowing users to create tags under the entity type. +- `UpdatePolicies`: List of policy names allowing users to update tags under the entity type. +- `DeletePolicies`: List of policy names allowing users to delete tags under the entity type. + +# Internals + +## Domain Layer + +#### Aggregates + +This module follows the [Entity Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Entities) guide. + +##### Tag + +A tag represents a tag under the entity type. + +- `Tag` (aggregate root): Represents a tag in the system. + +##### EntityTag + +An entity tag represents a connection between the tag and the tagged entity. + +- `EntityTag`(entity): Represents a connection between the tag and the tagged entity. + +#### Repositories + +This module follows the [Repository Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Repositories) guide. + +Following custom repositories are defined for this feature: + +- `ITagRepository` +- `IEntityTagRepository` + +#### Domain services + +This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide. + +##### Tag Manager + +`TagManager` is used to perform some operations for the `Tag` aggregate root. + +##### Entity Tag Manager + +`EntityTagManager` is used to perform some operations for the `EntityTag` entity. + +### Application layer + +#### Application services + +- `TagAdminAppService` (implements `ITagAdminAppService`): Implements the use cases of tag management. +- `EntityTagAdminAppService` (implements `IEntityTagAdminAppService`): Implements the use cases of entity tag relationship. +- `TagAppService` (implements `ITagAppService`): Implements the use cases of entity tag relationship for public websites. + +### Database providers + +#### Common + +##### Table / collection prefix & schema + +All tables/collections use the `Cms` prefix by default. Set static properties on the `CmsKitDbProperties` class if you need to change the table prefix or set a schema name (if supported by your database provider). + +##### Connection string + +This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. + +See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. + +#### Entity Framework Core + +##### Tables + +- CmsTags +- CmsEntityTags + - CmsTags + +#### MongoDB + +##### Collections + +- **CmsTags** +- **CmsEntityTags** + +### MVC UI + +The tag system provides a tag widget to display associated tags of the resource on public websites. You can simply place the widget on a page like below. + +```csharp +@await Component.InvokeAsync(typeof(TagViewComponent), new +{ + entityType = "entityType", + entityId = "entityId" +}) +``` + +For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation. \ No newline at end of file diff --git a/docs/en/MongoDB.md b/docs/en/MongoDB.md index a12d216b3d..5bcdfe7730 100644 --- a/docs/en/MongoDB.md +++ b/docs/en/MongoDB.md @@ -292,6 +292,24 @@ Configure(options => ### Advanced Topics +### Controlling the Multi-Tenancy + +If your solution is [multi-tenant](Multi-Tenancy.md), tenants may have **separate databases**, you have **multiple** `DbContext` classes in your solution and some of your `DbContext` classes should be usable **only from the host side**, it is suggested to add `[IgnoreMultiTenancy]` attribute on your `DbContext` class. In this case, ABP guarantees that the related `DbContext` always uses the host [connection string](Connection-Strings.md), even if you are in a tenant context. + +**Example:** + +````csharp +[IgnoreMultiTenancy] +public class MyDbContext : AbpMongoDbContext +{ + ... +} +```` + +Do not use the `[IgnoreMultiTenancy]` attribute if any one of your entities in your `DbContext` can be persisted in a tenant database. + +> When you use repositories, ABP already uses the host database for the entities don't implement the `IMultiTenant` interface. So, most of time you don't need to `[IgnoreMultiTenancy]` attribute if you are using the repositories to work with the database. + #### Set Default Repository Classes Default generic repositories are implemented by `MongoDbRepository` class by default. You can create your own implementation and use it for default repository implementation. diff --git a/docs/en/UI/Angular/Page-Component.md b/docs/en/UI/Angular/Page-Component.md index a9e9857142..912b516baf 100644 --- a/docs/en/UI/Angular/Page-Component.md +++ b/docs/en/UI/Angular/Page-Component.md @@ -1,4 +1,4 @@ -# Page Component +# Page Component ABP provides a component that wraps your content with some built-in components to reduce the amount of code you need to write. @@ -11,7 +11,7 @@ Let's look at the following example without `abp-page` component. ```html
-

{{ '::Dashboard' | abpLocalization }}

+

{%{{{ '::Dashboard' | abpLocalization }}}%}

``` -## Page Parts +## Page Parts PageComponent divides the template shown above into three parts, `title`, `breadcrumb`, `toolbar`. Each can be configured separately. There, also, is an enum exported from the package that describes each part. @@ -67,41 +67,35 @@ And change the template of `dashboard.component.ts` to the following: ``` -## Inputs +## Inputs * title: `string`: Will be be rendered within `h1.content-header-title`. If not provided, the parent `div` will not be rendered * breadcrumb: `boolean`: Determines whether to render `abp-breadcrumb`. Default is `true`. * toolbar: `any`: Will be passed into `abp-page-toolbar` component through `record` input. If your page does not contain `abp-page-toolbar`, you can simply omit this field. -## Overriding template +## Overriding template If you need to replace the template of any part, you can use the following sub-components. ```html - -
-

Custom Title

-
+ +

Custom Title

- -
- -
+ + - -
- -
+ +
``` You do not have to provide them all. You can just use which one you need to replace. These components have priority over the inputs declared above. If you use these components, you can omit the inputs. -## PagePartDirective +## PagePartDirective `PageModule` provides a structural directive that is used internally within `PageComponent` and can also be used externally. diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 0a7722de78..8aae7ac96b 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -39,31 +39,6 @@ } ] }, - { - "text": "Startup Templates", - "items": [ - { - "text": "Overall", - "path": "Startup-Templates/Index.md" - }, - { - "text": "Application", - "path": "Startup-Templates/Application.md" - }, - { - "text": "Module", - "path": "Startup-Templates/Module.md" - }, - { - "text": "Console", - "path": "Startup-Templates/Console.md" - }, - { - "text": "WPF", - "path": "Startup-Templates/WPF.md" - } - ] - }, { "text": "Tutorials", "items": [ @@ -122,6 +97,45 @@ } ] }, + { + "text": "CLI", + "path": "CLI.md", + "items": [ + { + "text": "Build Command", + "path": "CLI-BuildCommand.md" + }, + { + "text": "Create Solution Sample Commands", + "path": "CLI-New-Command-Samples.md" + } + ] + }, + { + "text": "Startup Templates", + "items": [ + { + "text": "Overall", + "path": "Startup-Templates/Index.md" + }, + { + "text": "Application", + "path": "Startup-Templates/Application.md" + }, + { + "text": "Module", + "path": "Startup-Templates/Module.md" + }, + { + "text": "Console", + "path": "Startup-Templates/Console.md" + }, + { + "text": "WPF", + "path": "Startup-Templates/WPF.md" + } + ] + }, { "text": "Fundamentals", "items": [ @@ -1292,25 +1306,6 @@ } ] }, - { - "text": "Reference", - "items": [ - { - "text": "CLI", - "path": "CLI.md", - "items": [ - { - "text": "Build Command", - "path": "CLI-BuildCommand.md" - }, - { - "text": "Create Solution Sample Commands", - "path": "CLI-New-Command-Samples.md" - } - ] - } - ] - }, { "text": "Contribution Guide", "path": "Contribution/Index.md" diff --git a/docs/en/images/cmskit-module-blog-post-edit.png b/docs/en/images/cmskit-module-blog-post-edit.png new file mode 100644 index 0000000000..528bc6b499 Binary files /dev/null and b/docs/en/images/cmskit-module-blog-post-edit.png differ diff --git a/docs/en/images/cmskit-module-blog-posts-page.png b/docs/en/images/cmskit-module-blog-posts-page.png new file mode 100644 index 0000000000..64d5d0e934 Binary files /dev/null and b/docs/en/images/cmskit-module-blog-posts-page.png differ diff --git a/docs/en/images/cmskit-module-blogs-edit.png b/docs/en/images/cmskit-module-blogs-edit.png new file mode 100644 index 0000000000..b2da4e5b5a Binary files /dev/null and b/docs/en/images/cmskit-module-blogs-edit.png differ diff --git a/docs/en/images/cmskit-module-blogs-feature-action.png b/docs/en/images/cmskit-module-blogs-feature-action.png new file mode 100644 index 0000000000..c0f0b1d3f4 Binary files /dev/null and b/docs/en/images/cmskit-module-blogs-feature-action.png differ diff --git a/docs/en/images/cmskit-module-blogs-page.png b/docs/en/images/cmskit-module-blogs-page.png new file mode 100644 index 0000000000..6c150429b7 Binary files /dev/null and b/docs/en/images/cmskit-module-blogs-page.png differ diff --git a/docs/en/images/cmskit-module-comment-page.png b/docs/en/images/cmskit-module-comment-page.png new file mode 100644 index 0000000000..6647a6dd09 Binary files /dev/null and b/docs/en/images/cmskit-module-comment-page.png differ diff --git a/docs/en/images/cmskit-module-comments-detail.png b/docs/en/images/cmskit-module-comments-detail.png new file mode 100644 index 0000000000..686a70e1f8 Binary files /dev/null and b/docs/en/images/cmskit-module-comments-detail.png differ diff --git a/docs/en/images/cmskit-module-features-dialog.png b/docs/en/images/cmskit-module-features-dialog.png new file mode 100644 index 0000000000..23aa2aa17a Binary files /dev/null and b/docs/en/images/cmskit-module-features-dialog.png differ diff --git a/docs/en/images/cmskit-module-pages-edit.png b/docs/en/images/cmskit-module-pages-edit.png new file mode 100644 index 0000000000..cca074fdac Binary files /dev/null and b/docs/en/images/cmskit-module-pages-edit.png differ diff --git a/docs/en/images/cmskit-module-pages-page.png b/docs/en/images/cmskit-module-pages-page.png new file mode 100644 index 0000000000..b64915493c Binary files /dev/null and b/docs/en/images/cmskit-module-pages-page.png differ diff --git a/docs/en/images/cmskit-module-ratings.png b/docs/en/images/cmskit-module-ratings.png new file mode 100644 index 0000000000..f97c934f15 Binary files /dev/null and b/docs/en/images/cmskit-module-ratings.png differ diff --git a/docs/en/images/cmskit-module-reactions.png b/docs/en/images/cmskit-module-reactions.png new file mode 100644 index 0000000000..b915b85f91 Binary files /dev/null and b/docs/en/images/cmskit-module-reactions.png differ diff --git a/docs/en/images/cmskit-module-tag-edit.png b/docs/en/images/cmskit-module-tag-edit.png new file mode 100644 index 0000000000..eb1ebb3a52 Binary files /dev/null and b/docs/en/images/cmskit-module-tag-edit.png differ diff --git a/docs/en/images/cmskit-module-tags-page.png b/docs/en/images/cmskit-module-tags-page.png new file mode 100644 index 0000000000..f41b6ecbd0 Binary files /dev/null and b/docs/en/images/cmskit-module-tags-page.png differ diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs index e98280d19d..160e66f49f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Volo.Abp.AspNetCore.MultiTenancy; namespace Microsoft.Extensions.DependencyInjection @@ -35,6 +36,17 @@ namespace Microsoft.Extensions.DependencyInjection SetAbpTenantId(receivedContext); return authorizationCodeReceived.Invoke(receivedContext); }; + + options.Events.OnRemoteFailure = remoteFailureContext => + { + if (remoteFailureContext.Failure is OpenIdConnectProtocolException && + remoteFailureContext.Failure.Message.Contains("access_denied")) + { + remoteFailureContext.HandleResponse(); + remoteFailureContext.Response.Redirect($"{remoteFailureContext.Request.PathBase}/"); + } + return Task.CompletedTask; + }; }); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/AppWithoutAuth.razor b/framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/AppWithoutAuth.razor new file mode 100644 index 0000000000..e9bf522595 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/AppWithoutAuth.razor @@ -0,0 +1,14 @@ +@using Microsoft.Extensions.Options +@using Volo.Abp.AspNetCore.Components.Web.Theming.Routing +@inject IOptions RouterOptions + + + + + + +

Sorry, there's nothing at this address.

+
+
+
\ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs index 281b2f7ded..787bf5cb6e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs @@ -1,5 +1,6 @@ using System.Security.Claims; using System.Threading.Tasks; +using JetBrains.Annotations; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; @@ -14,21 +15,29 @@ namespace Volo.Abp.AspNetCore.Components.Web.Security { public ClaimsPrincipal Principal { get; private set; } + [CanBeNull] private readonly AuthenticationStateProvider _authenticationStateProvider; - public AbpComponentsClaimsCache(IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) + public AbpComponentsClaimsCache( + IClientScopeServiceProviderAccessor serviceProviderAccessor) { - _authenticationStateProvider = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); - _authenticationStateProvider.AuthenticationStateChanged += async (task) => + _authenticationStateProvider = serviceProviderAccessor.ServiceProvider.GetService(); + if (_authenticationStateProvider != null) { - Principal = (await task).User; - }; + _authenticationStateProvider.AuthenticationStateChanged += async (task) => + { + Principal = (await task).User; + }; + } } public virtual async Task InitializeAsync() { - var authenticationState = await _authenticationStateProvider.GetAuthenticationStateAsync(); - Principal = authenticationState.User; + if (_authenticationStateProvider != null) + { + var authenticationState = await _authenticationStateProvider.GetAuthenticationStateAsync(); + Principal = authenticationState.User; + } } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs index ab2a73a8dd..b853670d39 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs @@ -1,7 +1,10 @@ using System.Threading.Tasks; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic; using Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic; +using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme { @@ -12,7 +15,15 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme if (context.Toolbar.Name == StandardToolbars.Main) { context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch))); - context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay))); + + //TODO: Can we find a different way to understand if authentication was configured or not? + var authenticationStateProvider = context.ServiceProvider + .GetService(); + + if (authenticationStateProvider != null) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay))); + } } return Task.CompletedTask; diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor index eebfb501a5..1b084a60ce 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor @@ -1,13 +1,12 @@ -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication -@using Microsoft.Extensions.Localization +@using Microsoft.Extensions.Localization @using Volo.Abp.Users @using Volo.Abp.MultiTenancy @using global::Localization.Resources.AbpUi +@inherits AbpComponentBase @inject ICurrentUser CurrentUser @inject ICurrentTenant CurrentTenant @inject IJSRuntime JsRuntime @inject NavigationManager Navigation -@inject SignOutSessionStateManager SignOutManager @inject IStringLocalizer UiLocalizer @@ -38,24 +37,4 @@ @UiLocalizer["Login"] - -@code{ - - private async Task NavigateToAsync(string uri, string target = null) - { - if (target == "_blank") - { - await JsRuntime.InvokeVoidAsync("open", uri, target); - } - else - { - Navigation.NavigateTo(uri); - } - } - - private async Task BeginSignOut() - { - await SignOutManager.SetSignOutState(); - await NavigateToAsync("authentication/logout"); - } -} + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs index addef3dc80..0ec9caa23c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs @@ -1,8 +1,11 @@ using System; using System.Threading.Tasks; +using JetBrains.Annotations; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.WebAssembly.Authentication; +using Microsoft.JSInterop; using Volo.Abp.UI.Navigation; namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic @@ -11,23 +14,32 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic { [Inject] protected IMenuManager MenuManager { get; set; } - - [Inject] - protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } - protected ApplicationMenu Menu { get; set; } + [CanBeNull] + protected AuthenticationStateProvider AuthenticationStateProvider; + + [CanBeNull] + protected SignOutSessionStateManager SignOutManager; + protected ApplicationMenu Menu { get; set; } + protected override async Task OnInitializedAsync() { Menu = await MenuManager.GetAsync(StandardMenus.User); Navigation.LocationChanged += OnLocationChanged; - AuthenticationStateProvider.AuthenticationStateChanged += async (task) => + LazyGetService(ref AuthenticationStateProvider); + LazyGetService(ref SignOutManager); + + if (AuthenticationStateProvider != null) { - Menu = await MenuManager.GetAsync(StandardMenus.User); - await InvokeAsync(StateHasChanged); - }; + AuthenticationStateProvider.AuthenticationStateChanged += async (task) => + { + Menu = await MenuManager.GetAsync(StandardMenus.User); + await InvokeAsync(StateHasChanged); + }; + } } protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) @@ -39,5 +51,26 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic { Navigation.LocationChanged -= OnLocationChanged; } + + private async Task NavigateToAsync(string uri, string target = null) + { + if (target == "_blank") + { + await JsRuntime.InvokeVoidAsync("open", uri, target); + } + else + { + Navigation.NavigateTo(uri); + } + } + + private async Task BeginSignOut() + { + if (SignOutManager != null) + { + await SignOutManager.SetSignOutState(); + await NavigateToAsync("authentication/logout"); + } + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs index bc4db53002..163b2217fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs @@ -108,6 +108,18 @@ namespace Volo.Abp.AspNetCore.Components return reference; } + + protected TService LazyGetService(ref TService reference) => LazyGetService(typeof(TService), ref reference); + + protected TRef LazyGetService(Type serviceType, ref TRef reference) + { + if (reference == null) + { + reference = (TRef)ScopedServices.GetService(serviceType); + } + + return reference; + } protected TService LazyGetNonScopedRequiredService(ref TService reference) => LazyGetNonScopedRequiredService(typeof(TService), ref reference); @@ -120,6 +132,18 @@ namespace Volo.Abp.AspNetCore.Components return reference; } + + protected TService LazyGetNonScopedService(ref TService reference) => LazyGetNonScopedService(typeof(TService), ref reference); + + protected TRef LazyGetNonScopedService(Type serviceType, ref TRef reference) + { + if (reference == null) + { + reference = (TRef)NonScopedServices.GetService(serviceType); + } + + return reference; + } [Inject] protected IServiceProvider NonScopedServices { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs index d85622f0cf..6f834b18ea 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs @@ -10,5 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy public Guid? TenantId { get; set; } public string Name { get; set; } + + public bool IsActive { get; set; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs index d0bea87196..60bdb523ba 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs @@ -28,10 +28,11 @@ namespace Pages.Abp.MultiTenancy { Success = true, TenantId = tenant.Id, - Name = tenant.Name + Name = tenant.Name, + IsActive = tenant.IsActive }; } - + public async Task FindTenantByIdAsync(Guid id) { var tenant = await TenantStore.FindAsync(id); @@ -45,8 +46,9 @@ namespace Pages.Abp.MultiTenancy { Success = true, TenantId = tenant.Id, - Name = tenant.Name + Name = tenant.Name, + IsActive = tenant.IsActive }; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs index bfdbb98db8..f47edab789 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs @@ -20,7 +20,7 @@ namespace Pages.Abp.MultiTenancy protected AbpAspNetCoreMultiTenancyOptions Options { get; } public TenantSwitchModalModel( - ITenantStore tenantStore, + ITenantStore tenantStore, IOptions options) { TenantStore = tenantStore; @@ -49,6 +49,11 @@ namespace Pages.Abp.MultiTenancy { var tenant = await TenantStore.FindAsync(Input.Name); if (tenant == null) + { + throw new UserFriendlyException(L["GivenTenantIsNotExist", Input.Name]); + } + + if (!tenant.IsActive) { throw new UserFriendlyException(L["GivenTenantIsNotAvailable", Input.Name]); } @@ -71,4 +76,4 @@ namespace Pages.Abp.MultiTenancy public string Name { get; set; } } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ar.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ar.json index 7e5f26edc6..fafc04a6ee 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ar.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ar.json @@ -1,6 +1,7 @@ { "culture": "ar", "texts": { + "GivenTenantIsNotExist": "المستأجر المحدد غير موجود: {0}", "GivenTenantIsNotAvailable": "الجهة المحددة غير متاحة: {0}", "Tenant": "الجهة", "Switch": "تغيير", @@ -9,4 +10,4 @@ "SwitchTenant": "تغيير الجهة", "NotSelected": "غير محدد" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/cs.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/cs.json index 05457dfa16..0f63728c77 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/cs.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/cs.json @@ -1,6 +1,7 @@ { "culture": "cs", "texts": { + "GivenTenantIsNotExist": "Vybraný tenant neexistuje: {0}", "GivenTenantIsNotAvailable": "Zvolený tenant není dostupný: {0}", "Tenant": "Tenant", "Switch": "změnit", diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de-DE.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de-DE.json index 3b1f12c29d..a0bb43999a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de-DE.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de-DE.json @@ -1,6 +1,7 @@ { "culture": "de-DE", "texts": { + "GivenTenantIsNotExist": "Der angegebene Client ist nicht vorhanden: {0}", "GivenTenantIsNotAvailable": "Der angegebene Mandant ist nicht verfügbar: {0}", "Tenant": "Mandant", "Switch": "wechseln", @@ -9,4 +10,4 @@ "SwitchTenant": "Mandant wechseln", "NotSelected": "Nicht ausgewählt" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json index 98909d9847..029e7ed76a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json @@ -1,6 +1,7 @@ { "culture": "de", "texts": { + "GivenTenantIsNotExist": "Der angegebene Client ist nicht vorhanden: {0}", "GivenTenantIsNotAvailable": "Der angegebene Mandant ist nicht verfügbar: {0}", "Tenant": "Mandant", "Switch": "wechseln", @@ -9,4 +10,4 @@ "SwitchTenant": "Mandant wechseln", "NotSelected": "Nicht ausgewählt" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en-GB.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en-GB.json index be5593fbd3..e93e7ef25e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en-GB.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en-GB.json @@ -1,6 +1,7 @@ { "culture": "en-GB", "texts": { + "GivenTenantIsNotExist": "Given tenant is not exist: {0}", "GivenTenantIsNotAvailable": "Given tenant is not available: {0}", "Tenant": "Tenant", "Switch": "switch", @@ -9,4 +10,4 @@ "SwitchTenant": "Switch tenant", "NotSelected": "Not selected" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en.json index d1a9f1f09e..25516ba765 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/en.json @@ -1,6 +1,7 @@ { "culture": "en", "texts": { + "GivenTenantIsNotExist": "Given tenant is not exist: {0}", "GivenTenantIsNotAvailable": "Given tenant is not available: {0}", "Tenant": "Tenant", "Switch": "switch", @@ -9,4 +10,4 @@ "SwitchTenant": "Switch tenant", "NotSelected": "Not selected" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es-mx.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es-mx.json index 746f1dec0f..5cd08ab345 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es-mx.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es-mx.json @@ -1,6 +1,7 @@ { "culture": "es-MX", "texts": { + "GivenTenantIsNotExist": "El inquilino {0} no existe", "GivenTenantIsNotAvailable": "El inquilino {0} no está disponible", "Tenant": "Inquilino", "Switch": "cambiar", diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es.json index d6fd84dcbe..bd2d82a2d0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/es.json @@ -1,6 +1,7 @@ { "culture": "es", "texts": { + "GivenTenantIsNotExist": "El inquilino {0} no existe", "GivenTenantIsNotAvailable": "El inquilino {0} no está disponible", "Tenant": "Inquilino", "Switch": "cambiar", @@ -9,4 +10,4 @@ "SwitchTenantHint": "Deje en blanco el campo nombre para cambiar el lado del host.", "NotSelected": "No seleccionado" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fi.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fi.json index 7cbeabe8cd..d6fb04eb4c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fi.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fi.json @@ -1,6 +1,7 @@ { "culture": "fi", "texts": { + "GivenTenantIsNotExist": "Annettua vuokralaista ei ole olemassa: {0}", "GivenTenantIsNotAvailable": "Annettua vuokralaista ei ole saatavilla: {0}", "Tenant": "Vuokralainen", "Switch": "vaihtaa", @@ -9,4 +10,4 @@ "SwitchTenant": "Vaihda vuokralainen", "NotSelected": "Ei valittu" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fr.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fr.json index dbd17957fc..6fe00242b5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fr.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/fr.json @@ -1,6 +1,7 @@ { "culture": "fr", "texts": { + "GivenTenantIsNotExist": "Adott bérlő nem létezik: {0}", "GivenTenantIsNotAvailable": "Le Tenant donné n'est pas disponible: {0}", "Tenant": "Tenant", "Switch": "Changer", @@ -9,4 +10,4 @@ "SwitchTenant": "Changer le Tenant", "NotSelected": "Non séléctionné" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/hu.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/hu.json index 057e9d2968..108b3520d7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/hu.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/hu.json @@ -1,6 +1,7 @@ { "culture": "hu", "texts": { + "GivenTenantIsNotExist": "Adott bérlő nem létezik: {0}", "GivenTenantIsNotAvailable": "A megadott előfizető nem érhető el: {0}", "Tenant": "Előfizető", "Switch": "váltás", @@ -9,4 +10,4 @@ "SwitchTenant": "Előfizető váltás", "NotSelected": "Nincs kiválasztva" } - } \ No newline at end of file + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json index ea15166b9e..3cbb689f03 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json @@ -1,6 +1,7 @@ { "culture": "nl", "texts": { + "GivenTenantIsNotExist": "Opgegeven huurder bestaat niet: {0}", "GivenTenantIsNotAvailable": "Gegeven klant is niet beschikbaar: {0}", "Tenant": "Klant", "Switch": "Schakel over", @@ -9,4 +10,4 @@ "SwitchTenant": "Klant wisselen", "NotSelected": "Niet geselecteerd" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json index 438d770a7c..79d3e9640d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json @@ -1,6 +1,7 @@ { "culture": "pl-PL", "texts": { + "GivenTenantIsNotExist": "Podany najemca nie istnieje: {0}", "GivenTenantIsNotAvailable": "Podany tenant jest niedostępny: {0}", "Tenant": "Tenant", "Switch": "zmień", @@ -8,4 +9,4 @@ "SwitchTenantHint": "Pozostaw pole nazwy puste, aby przełączyć się na stronę hosta.", "NotSelected": "Nie wybrano" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pt-BR.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pt-BR.json index 8ac517d594..95396abca1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pt-BR.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pt-BR.json @@ -1,6 +1,7 @@ { "culture": "pt-BR", "texts": { + "GivenTenantIsNotExist": "O inquilino dado não existe: {0}", "GivenTenantIsNotAvailable": "Inquilino não está disponível: {0}", "Tenant": "Inquilino", "Switch": "trocar", @@ -9,4 +10,4 @@ "SwitchTenant": "Alterar Inquilino", "NotSelected": "Não selecionado" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ru.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ru.json index 04b2e5cf85..5492a7d7bb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ru.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/ru.json @@ -1,6 +1,7 @@ { "culture": "ru", "texts": { + "GivenTenantIsNotExist": "Данный арендатор не существует: {0}", "GivenTenantIsNotAvailable": "Данный арендатор недоступен: {0}", "Tenant": "Арендатор", "Switch": "переключиться", diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/sl.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/sl.json index 51938a569e..b1a07d3ee9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/sl.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/sl.json @@ -1,6 +1,7 @@ { "culture": "sl", "texts": { + "GivenTenantIsNotExist": "Dani najemnik ne obstaja: {0}", "GivenTenantIsNotAvailable": "Najemnik ni na voljo: {0}", "Tenant": "Najemnik", "Switch": "Zamenjaj", diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/tr.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/tr.json index 994579e934..b5b6c374c1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/tr.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/tr.json @@ -1,6 +1,7 @@ { "culture": "tr", "texts": { + "GivenTenantIsNotExist": "İstenilen müşteri bulunamadı: {0}", "GivenTenantIsNotAvailable": "İstenilen müşteri bulunamadı: {0}", "Tenant": "Müşteri", "Switch": "değiştir", @@ -9,4 +10,4 @@ "SwitchTenant": "Müşteri değiştir", "NotSelected": "Seçili değil" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/vi.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/vi.json index 975e1b4590..b8ad08bb82 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/vi.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/vi.json @@ -1,6 +1,7 @@ { "culture": "vi", "texts": { + "GivenTenantIsNotExist": "Người thuê đã cho không tồn tại: {0}", "GivenTenantIsNotAvailable": "Người thuê không có sẵn: {0}", "Tenant": "Người thuê", "Switch": "Chuyển đổi", diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json index 31588cbebd..0e86d66293 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json @@ -1,6 +1,7 @@ { "culture": "zh-Hans", "texts": { + "GivenTenantIsNotExist": "给定的租户不存在: {0}", "GivenTenantIsNotAvailable": "给定的租户不可用: {0}", "Tenant": "租户", "Switch": "切换", @@ -9,4 +10,4 @@ "SwitchTenant": "切换租户", "NotSelected": "未选中" } - } \ No newline at end of file + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hant.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hant.json index 12eea67007..10a0da1023 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hant.json +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hant.json @@ -1,6 +1,7 @@ { "culture": "zh-Hant", "texts": { + "GivenTenantIsNotExist": "指定的租戶不存在: {0}", "GivenTenantIsNotAvailable": "指定的租戶不可用: {0}", "SwitchTenant": "切換租戶", "Name": "名稱", @@ -9,4 +10,4 @@ "Switch": "切換", "NotSelected": "尚未選定" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs index 4676202c24..f7cba501c3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs @@ -1,9 +1,11 @@ using System; +using System.Collections.Generic; using JetBrains.Annotations; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars { - public class ToolbarItem + public class ToolbarItem : IHasSimpleStateCheckers { public Type ComponentType { @@ -15,13 +17,17 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars public int Order { get; set; } [CanBeNull] + [Obsolete("Use RequirePermissions extension method.")] public string RequiredPermissionName { get; set; } + public List> StateCheckers { get; } + public ToolbarItem([NotNull] Type componentType, int order = 0, string requiredPermissionName = null) { Order = order; ComponentType = Check.NotNull(componentType, nameof(componentType)); RequiredPermissionName = requiredPermissionName; + StateCheckers = new List>(); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs index 2e97cebecb..d27ab355c0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.UI.Theming; using Volo.Abp.Authorization.Permissions; using Volo.Abp.DependencyInjection; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars { @@ -15,13 +16,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars protected IThemeManager ThemeManager { get; } protected AbpToolbarOptions Options { get; } protected IServiceProvider ServiceProvider { get; } + protected ISimpleStateCheckerManager SimpleStateCheckerManager { get; } public ToolbarManager( IOptions options, IServiceProvider serviceProvider, - IThemeManager themeManager) + IThemeManager themeManager, + ISimpleStateCheckerManager simpleStateCheckerManager) { ThemeManager = themeManager; + SimpleStateCheckerManager = simpleStateCheckerManager; ServiceProvider = serviceProvider; Options = options.Value; } @@ -47,17 +51,20 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars protected virtual async Task CheckPermissionsAsync(IServiceProvider serviceProvider, Toolbar toolbar) { - var requiredPermissionItems = toolbar.Items.Where(x => !x.RequiredPermissionName.IsNullOrWhiteSpace()).ToList(); + foreach (var item in toolbar.Items.Where(x => !x.RequiredPermissionName.IsNullOrWhiteSpace())) + { + item.RequirePermissions(item.RequiredPermissionName); + } - if (requiredPermissionItems.Any()) + var checkPermissionsToolbarItems = toolbar.Items.Where(x => x.StateCheckers.Any()).ToArray(); + if (checkPermissionsToolbarItems.Any()) { - var permissionChecker = serviceProvider.GetRequiredService(); - var grantResult = await permissionChecker.IsGrantedAsync(requiredPermissionItems.Select(x => x.RequiredPermissionName).Distinct().ToArray()); + var result = await SimpleStateCheckerManager.IsEnabledAsync(checkPermissionsToolbarItems); var toBeDeleted = new HashSet(); - foreach (var item in requiredPermissionItems) + foreach (var item in checkPermissionsToolbarItems) { - if (grantResult.Result[item.RequiredPermissionName!] != PermissionGrantResult.Granted) + if (!result[item]) { toBeDeleted.Add(item); } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AbpPermissionOptions.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AbpPermissionOptions.cs index eb2ac920ac..ce9dc06798 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AbpPermissionOptions.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AbpPermissionOptions.cs @@ -8,13 +8,10 @@ namespace Volo.Abp.Authorization.Permissions public ITypeList ValueProviders { get; } - public ITypeList GlobalStateProviders { get; } - public AbpPermissionOptions() { DefinitionProviders = new TypeList(); ValueProviders = new TypeList(); - GlobalStateProviders = new TypeList(); } } } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateManager.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateManager.cs deleted file mode 100644 index 6195e02545..0000000000 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateManager.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading.Tasks; - -namespace Volo.Abp.Authorization.Permissions -{ - public interface IPermissionStateManager - { - Task IsEnabledAsync(PermissionDefinition permission); - } -} diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateProvider.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateProvider.cs deleted file mode 100644 index 7bc3087f50..0000000000 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionStateProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading.Tasks; - -namespace Volo.Abp.Authorization.Permissions -{ - public interface IPermissionStateProvider - { - Task IsEnabledAsync(PermissionStateContext context); - } -} diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs index ac525367ad..92eda28b4b 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs @@ -3,10 +3,11 @@ using System.Collections.Immutable; using JetBrains.Annotations; using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.Authorization.Permissions { - public class PermissionDefinition + public class PermissionDefinition : IHasSimpleStateCheckers { /// /// Unique name of the permission. @@ -31,7 +32,7 @@ namespace Volo.Abp.Authorization.Permissions /// public List Providers { get; } //TODO: Rename to AllowedProviders? - public List StateProviders { get; } + public List> StateCheckers { get; } public ILocalizableString DisplayName { @@ -88,7 +89,7 @@ namespace Volo.Abp.Authorization.Permissions Properties = new Dictionary(); Providers = new List(); - StateProviders = new List(); + StateCheckers = new List>(); _children = new List(); } @@ -123,7 +124,7 @@ namespace Volo.Abp.Authorization.Permissions } /// - /// Sets a property in the dictionary. + /// Set the property. /// This is a shortcut for nested calls on this object. /// public virtual PermissionDefinition WithProviders(params string[] providers) diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionExtensions.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionExtensions.cs deleted file mode 100644 index 7e5de5a1f1..0000000000 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using JetBrains.Annotations; - -namespace Volo.Abp.Authorization.Permissions -{ - public static class PermissionDefinitionExtensions - { - public static PermissionDefinition AddStateProviders( - [NotNull] this PermissionDefinition permissionDefinition, - [NotNull] params IPermissionStateProvider[] permissionStateProviders) - { - Check.NotNull(permissionDefinition, nameof(permissionDefinition)); - Check.NotNull(permissionStateProviders, nameof(permissionStateProviders)); - - permissionDefinition.StateProviders.AddRange(permissionStateProviders); - - return permissionDefinition; - } - } -} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs index d243c9c54c..234fbf7ea2 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; using Volo.Abp.Security.Claims; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.Authorization.Permissions { @@ -15,20 +16,20 @@ namespace Volo.Abp.Authorization.Permissions protected ICurrentPrincipalAccessor PrincipalAccessor { get; } protected ICurrentTenant CurrentTenant { get; } protected IPermissionValueProviderManager PermissionValueProviderManager { get; } - protected IPermissionStateManager PermissionStateManager { get; } + protected ISimpleStateCheckerManager StateCheckerManager { get; } public PermissionChecker( ICurrentPrincipalAccessor principalAccessor, IPermissionDefinitionManager permissionDefinitionManager, ICurrentTenant currentTenant, IPermissionValueProviderManager permissionValueProviderManager, - IPermissionStateManager permissionStateManager) + ISimpleStateCheckerManager stateCheckerManager) { PrincipalAccessor = principalAccessor; PermissionDefinitionManager = permissionDefinitionManager; CurrentTenant = currentTenant; PermissionValueProviderManager = permissionValueProviderManager; - PermissionStateManager = permissionStateManager; + StateCheckerManager = stateCheckerManager; } public virtual async Task IsGrantedAsync(string name) @@ -49,7 +50,7 @@ namespace Volo.Abp.Authorization.Permissions return false; } - if (!await PermissionStateManager.IsEnabledAsync(permission)) + if (!await StateCheckerManager.IsEnabledAsync(permission)) { return false; } @@ -112,7 +113,7 @@ namespace Volo.Abp.Authorization.Permissions result.Result.Add(name, PermissionGrantResult.Undefined); if (permission.IsEnabled && - await PermissionStateManager.IsEnabledAsync(permission) && + await StateCheckerManager.IsEnabledAsync(permission) && permission.MultiTenancySide.HasFlag(multiTenancySide)) { permissionDefinitions.Add(permission); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionSimpleStateCheckerExtensions.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionSimpleStateCheckerExtensions.cs new file mode 100644 index 0000000000..5fc22cb93c --- /dev/null +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionSimpleStateCheckerExtensions.cs @@ -0,0 +1,57 @@ +using JetBrains.Annotations; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Authorization.Permissions +{ + public static class PermissionSimpleStateCheckerExtensions + { + public static TState RequireAuthenticated([NotNull] this TState state) + where TState : IHasSimpleStateCheckers + { + state.StateCheckers.Add(new RequireAuthenticatedSimpleStateChecker()); + return state; + } + + public static TState RequirePermissions( + [NotNull] this TState state, + params string[] permissions) + where TState : IHasSimpleStateCheckers + { + state.RequirePermissions(requiresAll: true, batchCheck: true, permissions); + return state; + } + + public static TState RequirePermissions( + [NotNull] this TState state, + bool requiresAll, + params string[] permissions) + where TState : IHasSimpleStateCheckers + { + state.RequirePermissions(requiresAll: requiresAll, batchCheck: true, permissions); + return state; + } + + public static TState RequirePermissions( + [NotNull] this TState state, + bool requiresAll, + bool batchCheck, + params string[] permissions) + where TState : IHasSimpleStateCheckers + { + Check.NotNull(state, nameof(state)); + Check.NotNullOrEmpty(permissions, nameof(permissions)); + + if (batchCheck) + { + RequirePermissionsSimpleBatchStateChecker.Instance.AddCheckModels(new RequirePermissionsSimpleBatchStateCheckerModel(state, permissions, requiresAll)); + state.StateCheckers.Add(RequirePermissionsSimpleBatchStateChecker.Instance); + } + else + { + state.StateCheckers.Add(new RequirePermissionsSimpleStateChecker(new RequirePermissionsSimpleBatchStateCheckerModel(state, permissions, requiresAll))); + } + + return state; + } + } +} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionStateManager.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionStateManager.cs deleted file mode 100644 index 957ed3c7a6..0000000000 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionStateManager.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.Authorization.Permissions -{ - public class PermissionStateManager : IPermissionStateManager, ITransientDependency - { - protected IServiceProvider ServiceProvider { get; } - protected AbpPermissionOptions Options { get; } - - public PermissionStateManager(IServiceProvider serviceProvider, IOptions options) - { - ServiceProvider = serviceProvider; - Options = options.Value; - } - - public async Task IsEnabledAsync(PermissionDefinition permission) - { - using (var scope = ServiceProvider.CreateScope()) - { - var context = new PermissionStateContext - { - Permission = permission, - ServiceProvider = scope.ServiceProvider.GetRequiredService() - }; - - foreach (var provider in permission.StateProviders) - { - if (!await provider.IsEnabledAsync(context)) - { - return false; - } - } - - foreach (IPermissionStateProvider provider in Options.GlobalStateProviders.Select(x => ServiceProvider.GetRequiredService(x))) - { - if (!await provider.IsEnabledAsync(context)) - { - return false; - } - } - - return true; - } - } - } -} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequireAuthenticatedSimpleStateChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequireAuthenticatedSimpleStateChecker.cs new file mode 100644 index 0000000000..64350bd825 --- /dev/null +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequireAuthenticatedSimpleStateChecker.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.SimpleStateChecking; +using Volo.Abp.Users; + +namespace Volo.Abp.Authorization.Permissions +{ + public class RequireAuthenticatedSimpleStateChecker : ISimpleStateChecker + where TState : IHasSimpleStateCheckers + { + public Task IsEnabledAsync(SimpleStateCheckerContext context) + { + return Task.FromResult(context.ServiceProvider.GetRequiredService().IsAuthenticated); + } + } +} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs new file mode 100644 index 0000000000..f02ce38c74 --- /dev/null +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Authorization.Permissions +{ + public class RequirePermissionsSimpleBatchStateChecker : SimpleBatchStateCheckerBase + where TState : IHasSimpleStateCheckers + { + public static readonly RequirePermissionsSimpleBatchStateChecker Instance = new RequirePermissionsSimpleBatchStateChecker(); + + private readonly List> _models; + + public RequirePermissionsSimpleBatchStateChecker() + { + _models = new List>(); + } + + public RequirePermissionsSimpleBatchStateChecker AddCheckModels(params RequirePermissionsSimpleBatchStateCheckerModel[] models) + { + Check.NotNullOrEmpty(models, nameof(models)); + + foreach (var model in models) + { + if (!_models.Any(x => x.State.GetType() == model.State.GetType() && + x.RequiresAll == model.RequiresAll && + x.Permissions.SequenceEqual(model.Permissions))) + { + _models.Add(model); + } + } + + return this; + } + + public override async Task> IsEnabledAsync(SimpleBatchStateCheckerContext context) + { + var permissionChecker = context.ServiceProvider.GetRequiredService(); + + var result = new SimpleStateCheckerResult(context.States); + + var permissions = _models.Where(x => context.States.Any(s => s.Equals(x.State))).SelectMany(x => x.Permissions).Distinct().ToArray(); + var grantResult = await permissionChecker.IsGrantedAsync(permissions); + + foreach (var state in context.States) + { + var model = _models.FirstOrDefault(x => x.State.Equals(state)); + if (model != null) + { + if (model.RequiresAll) + { + result[model.State] = model.Permissions.All(x => grantResult.Result.Any(y => y.Key == x && y.Value == PermissionGrantResult.Granted)); + } + else + { + result[model.State] = grantResult.Result.Any(x => model.Permissions.Contains(x.Key) && x.Value == PermissionGrantResult.Granted); + } + } + } + + return result; + } + } +} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateCheckerModel.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateCheckerModel.cs new file mode 100644 index 0000000000..3660d10f46 --- /dev/null +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateCheckerModel.cs @@ -0,0 +1,24 @@ +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Authorization.Permissions +{ + public class RequirePermissionsSimpleBatchStateCheckerModel + where TState : IHasSimpleStateCheckers + { + public TState State { get; } + + public string[] Permissions { get; } + + public bool RequiresAll { get; } + + public RequirePermissionsSimpleBatchStateCheckerModel(TState state, string[] permissions, bool requiresAll = true) + { + Check.NotNull(state, nameof(state)); + Check.NotNullOrEmpty(permissions, nameof(permissions)); + + State = state; + Permissions = permissions; + RequiresAll = requiresAll; + } + } +} diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleStateChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleStateChecker.cs new file mode 100644 index 0000000000..32cedeecc6 --- /dev/null +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleStateChecker.cs @@ -0,0 +1,34 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Authorization.Permissions +{ + public class RequirePermissionsSimpleStateChecker : ISimpleStateChecker + where TState : IHasSimpleStateCheckers + { + private readonly RequirePermissionsSimpleBatchStateCheckerModel _model; + + public RequirePermissionsSimpleStateChecker(RequirePermissionsSimpleBatchStateCheckerModel model) + { + _model = model; + } + + public async Task IsEnabledAsync(SimpleStateCheckerContext context) + { + var permissionChecker = context.ServiceProvider.GetRequiredService(); + + if (_model.Permissions.Length == 1) + { + return await permissionChecker.IsGrantedAsync(_model.Permissions.First()); + } + + var grantResult = await permissionChecker.IsGrantedAsync(_model.Permissions); + + return _model.RequiresAll + ? grantResult.AllGranted + : grantResult.Result.Any(x => _model.Permissions.Contains(x.Key) && x.Value == PermissionGrantResult.Granted); + } + } +} diff --git a/framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs b/framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs index 96caf956b1..776a8b9a7a 100644 --- a/framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs @@ -35,7 +35,11 @@ namespace Autofac.Builder return registrationBuilder; } - private static IRegistrationBuilder InvokeRegistrationActions(this IRegistrationBuilder registrationBuilder, ServiceRegistrationActionList registrationActionList, Type serviceType, Type implementationType) + private static IRegistrationBuilder InvokeRegistrationActions( + this IRegistrationBuilder registrationBuilder, + ServiceRegistrationActionList registrationActionList, + Type serviceType, + Type implementationType) where TActivatorData : ReflectionActivatorData { var serviceRegistredArgs = new OnServiceRegistredContext(serviceType, implementationType); @@ -48,6 +52,7 @@ namespace Autofac.Builder if (serviceRegistredArgs.Interceptors.Any()) { registrationBuilder = registrationBuilder.AddInterceptors( + registrationActionList, serviceType, serviceRegistredArgs.Interceptors ); @@ -71,10 +76,12 @@ namespace Autofac.Builder return registrationBuilder; } - private static IRegistrationBuilder AddInterceptors( - this IRegistrationBuilder registrationBuilder, - Type serviceType, - IEnumerable interceptors) + private static IRegistrationBuilder + AddInterceptors( + this IRegistrationBuilder registrationBuilder, + ServiceRegistrationActionList serviceRegistrationActionList, + Type serviceType, + IEnumerable interceptors) where TActivatorData : ReflectionActivatorData { if (serviceType.IsInterface) @@ -83,6 +90,11 @@ namespace Autofac.Builder } else { + if (serviceRegistrationActionList.IsClassInterceptorsDisabled) + { + return registrationBuilder; + } + (registrationBuilder as IRegistrationBuilder)?.EnableClassInterceptors(); } diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 6ce4a10a53..19ace62aca 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -485,16 +485,26 @@ namespace Volo.Abp.BlazoriseUI try { await CheckDeletePolicyAsync(); - + await OnDeletingEntityAsync(); await AppService.DeleteAsync(entity.Id); - await GetEntitiesAsync(); - await InvokeAsync(StateHasChanged); + await OnDeletedEntityAsync(); } catch (Exception ex) { await HandleErrorAsync(ex); } } + + protected virtual Task OnDeletingEntityAsync() + { + return Task.CompletedTask; + } + + protected virtual async Task OnDeletedEntityAsync() + { + await GetEntitiesAsync(); + await InvokeAsync(StateHasChanged); + } protected virtual string GetDeleteConfirmationMessage(TListViewModel entity) { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs index 330cbeb77a..ce6ab1e831 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs @@ -36,6 +36,7 @@ namespace Volo.Abp.Cli options.Commands["add-module"] = typeof(AddModuleCommand); options.Commands["list-modules"] = typeof(ListModulesCommand); options.Commands["login"] = typeof(LoginCommand); + options.Commands["login-info"] = typeof(LoginInfoCommand); options.Commands["logout"] = typeof(LogoutCommand); options.Commands[GenerateProxyCommand.Name] = typeof(GenerateProxyCommand); options.Commands[RemoveProxyCommand.Name] = typeof(RemoveProxyCommand); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs index 1dd29e5df7..b7cd95a3e0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.Args @@ -71,6 +72,11 @@ namespace Volo.Abp.Cli.Args return commandLineArgs; } + public CommandLineArgs Parse(string lineText) + { + return Parse(GetArgsArrayFromLine(lineText)); + } + private static bool IsOptionName(string argument) { return argument.StartsWith("-") || argument.StartsWith("--"); @@ -100,5 +106,46 @@ namespace Volo.Abp.Cli.Args throw new ArgumentException("Option names should start with '-' or '--'."); } + + private static string[] GetArgsArrayFromLine(string lineText) + { + var args = new List(); + var currentArgBuilder = new StringBuilder(); + string currentArg = null; + bool isInQuotes = false; + for (int i = 0; i < lineText.Length; i++) + { + var c = lineText[i]; + if (c == ' ' && !isInQuotes) + { + currentArg = currentArgBuilder.ToString(); + if (!currentArg.IsNullOrWhiteSpace()) + { + args.Add(currentArg); + } + + currentArgBuilder = new StringBuilder(); + } + else + { + if (c == '\"') + { + isInQuotes = !isInQuotes; + } + else + { + currentArgBuilder.Append(c); + } + } + } + + currentArg = currentArgBuilder.ToString(); + if (!currentArg.IsNullOrWhiteSpace()) + { + args.Add(currentArg); + } + + return args.ToArray(); + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs index c467541210..4e8ee7cd77 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs @@ -3,5 +3,7 @@ public interface ICommandLineArgumentParser { CommandLineArgs Parse(string[] args); + + CommandLineArgs Parse(string lineText); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs index 61008ee826..bb16733e16 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs @@ -9,8 +9,10 @@ using IdentityModel; using Microsoft.Extensions.Logging; using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Http; +using Volo.Abp.Cli.ProjectBuilding; using Volo.Abp.DependencyInjection; using Volo.Abp.IdentityModel; +using Volo.Abp.Json; using Volo.Abp.Threading; namespace Volo.Abp.Cli.Auth @@ -18,21 +20,54 @@ namespace Volo.Abp.Cli.Auth public class AuthService : ITransientDependency { protected IIdentityModelAuthenticationService AuthenticationService { get; } - protected ILogger Logger { get; } + protected ILogger Logger { get; } protected CliHttpClientFactory CliHttpClientFactory { get; } + public RemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; } + public IJsonSerializer JsonSerializer { get; } public ICancellationTokenProvider CancellationTokenProvider { get; } public AuthService( IIdentityModelAuthenticationService authenticationService, - ILogger logger, + ILogger logger, ICancellationTokenProvider cancellationTokenProvider, - CliHttpClientFactory cliHttpClientFactory + CliHttpClientFactory cliHttpClientFactory, + RemoteServiceExceptionHandler remoteServiceExceptionHandler, + IJsonSerializer jsonSerializer ) { AuthenticationService = authenticationService; Logger = logger; CancellationTokenProvider = cancellationTokenProvider; CliHttpClientFactory = cliHttpClientFactory; + RemoteServiceExceptionHandler = remoteServiceExceptionHandler; + JsonSerializer = jsonSerializer; + } + + public async Task GetLoginInfoAsync() + { + if (!IsLoggedIn()) + { + return null; + } + + var url = $"{CliUrls.WwwAbpIo}api/license/login-info"; + + var client = CliHttpClientFactory.CreateClient(); + + using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger)) + { + if (!response.IsSuccessStatusCode) + { + Logger.LogError("Remote server returns '{response.StatusCode}'"); + return null; + } + + await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response); + + var responseContent = await response.Content.ReadAsStringAsync(); + + return JsonSerializer.Deserialize(responseContent); + } } public async Task LoginAsync(string userName, string password, string organizationName = null) @@ -108,4 +143,4 @@ namespace Volo.Abp.Cli.Auth return File.Exists(CliPaths.AccessToken); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/LoginInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/LoginInfo.cs new file mode 100644 index 0000000000..2ad31421e5 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/LoginInfo.cs @@ -0,0 +1,16 @@ + +namespace Volo.Abp.Cli.Auth +{ + public class LoginInfo + { + public string Name { get; set; } + + public string Surname { get; set; } + + public string Username { get; set; } + + public string EmailAddress { get; set; } + + public string Organization { get; set; } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs index 11ba6dedde..cfae12c76e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs @@ -3,9 +3,11 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using NuGet.Versioning; using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Threading.Tasks; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands; @@ -41,33 +43,76 @@ namespace Volo.Abp.Cli { Logger.LogInformation("ABP CLI (https://abp.io)"); - var commandLineArgs = CommandLineArgumentParser.Parse(args); - #if !DEBUG if (!commandLineArgs.Options.ContainsKey("skip-cli-version-check")) { await CheckCliVersionAsync(); } #endif - - var commandType = CommandSelector.Select(commandLineArgs); - - using (var scope = ServiceScopeFactory.CreateScope()) + var commandLineArgs = CommandLineArgumentParser.Parse(args); + + try { - var command = (IConsoleCommand)scope.ServiceProvider.GetRequiredService(commandType); - - try + if (commandLineArgs.IsCommand("batch")) + { + await RunBatchAsync(commandLineArgs); + } + else { - await command.ExecuteAsync(commandLineArgs); + await RunInternalAsync(commandLineArgs); } - catch (CliUsageException usageException) + } + catch (CliUsageException usageException) + { + Logger.LogWarning(usageException.Message); + } + catch (Exception ex) + { + Logger.LogException(ex); + } + } + + private async Task RunBatchAsync(CommandLineArgs commandLineArgs) + { + var targetFile = commandLineArgs.Target; + if (targetFile.IsNullOrWhiteSpace()) + { + throw new CliUsageException( + "Must provide a file name/path that contains a list of commands" + + Environment.NewLine + Environment.NewLine + + "Example: " + + " abp batch commands.txt" + ); + } + + var filePath = Path.Combine(Directory.GetCurrentDirectory(), targetFile); + var fileLines = File.ReadAllLines(filePath); + foreach (var line in fileLines) + { + var lineText = line; + if (lineText.IsNullOrWhiteSpace() || lineText.StartsWith("#")) { - Logger.LogWarning(usageException.Message); + continue; } - catch (Exception ex) + + if (lineText.Contains('#')) { - Logger.LogException(ex); + lineText = lineText.Substring(0, lineText.IndexOf('#')); } + + var args = CommandLineArgumentParser.Parse(lineText); + await RunInternalAsync(args); + } + } + + private async Task RunInternalAsync(CommandLineArgs commandLineArgs) + { + var commandType = CommandSelector.Select(commandLineArgs); + + using (var scope = ServiceScopeFactory.CreateScope()) + { + var command = (IConsoleCommand) scope.ServiceProvider.GetRequiredService(commandType); + await command.ExecuteAsync(commandLineArgs); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginInfoCommand..cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginInfoCommand..cs new file mode 100644 index 0000000000..e5bd62c393 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginInfoCommand..cs @@ -0,0 +1,63 @@ +using System; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.Auth; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Cli.Commands +{ + public class LoginInfoCommand : IConsoleCommand, ITransientDependency + { + public ILogger Logger { get; set; } + + protected AuthService AuthService { get; } + + public LoginInfoCommand(AuthService authService) + { + AuthService = authService; + Logger = NullLogger.Instance; + } + + public async Task ExecuteAsync(CommandLineArgs commandLineArgs) + { + var loginInfo = await AuthService.GetLoginInfoAsync(); + + if (loginInfo == null) + { + Logger.LogError("Unable to get login info."); + return; + } + + var sb = new StringBuilder(); + sb.AppendLine(""); + sb.AppendLine($"Login info:"); + sb.AppendLine($"Name: {loginInfo.Name}"); + sb.AppendLine($"Surname: {loginInfo.Surname}"); + sb.AppendLine($"Username: {loginInfo.Username}"); + sb.AppendLine($"Email Address: {loginInfo.EmailAddress}"); + sb.AppendLine($"Organization: {loginInfo.Organization}"); + Logger.LogInformation(sb.ToString()); + } + + public string GetUsageInfo() + { + var sb = new StringBuilder(); + + sb.AppendLine(""); + sb.AppendLine("Usage:"); + sb.AppendLine(" abp login-info"); + sb.AppendLine(""); + sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI"); + + return sb.ToString(); + } + + public string GetShortDescription() + { + return "Show your login info."; + } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index 2d59392dcd..9a30fd7fd3 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -301,13 +301,21 @@ namespace Volo.Abp.Cli.ProjectModification private async Task RemoveProjectFromSolutionAsync(string moduleSolutionFile, string projectName) { - await SolutionFileModifier.RemoveProjectFromSolutionFileAsync(moduleSolutionFile, projectName); + await SolutionFileModifier.RemoveProjectFromSolutionFileAsync(moduleSolutionFile, projectName); - var projectFolderPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "src", projectName); + var projectFolderPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "src", projectName); + if (Directory.Exists(projectFolderPath)) + { + Directory.Delete(projectFolderPath, true); + } + else + { + projectFolderPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "test", projectName); if (Directory.Exists(projectFolderPath)) { Directory.Delete(projectFolderPath, true); } + } } private void ChangeDomainTestReferenceToMongoDB(ModuleWithMastersInfo module, string moduleSolutionFile) diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs index 59cbdec860..41676f00d5 100644 --- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs +++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs @@ -28,6 +28,16 @@ namespace Microsoft.Extensions.DependencyInjection return actionList; } + + public static void DisableAbpClassInterceptors(this IServiceCollection services) + { + GetOrCreateRegistrationActionList(services).IsClassInterceptorsDisabled = true; + } + + public static bool IsAbpClassInterceptorsDisabled(this IServiceCollection services) + { + return GetOrCreateRegistrationActionList(services).IsClassInterceptorsDisabled; + } // OnExposing diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs index bb72d28929..19ab6cdba2 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs @@ -5,6 +5,6 @@ namespace Volo.Abp.DependencyInjection { public class ServiceRegistrationActionList : List> { - + public bool IsClassInterceptorsDisabled { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/InternalServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/InternalServiceCollectionExtensions.cs index ee06003204..5c729b4197 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/InternalServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/InternalServiceCollectionExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Volo.Abp.Logging; using Volo.Abp.Modularity; using Volo.Abp.Reflection; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.Internal { @@ -40,6 +41,8 @@ namespace Volo.Abp.Internal services.AddAssemblyOf(); + services.AddTransient(typeof(ISimpleStateCheckerManager<>), typeof(SimpleStateCheckerManager<>)); + services.Configure(options => { options.Contributors.Add(); diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/AbpSimpleStateCheckerOptions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/AbpSimpleStateCheckerOptions.cs new file mode 100644 index 0000000000..66201449a1 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/AbpSimpleStateCheckerOptions.cs @@ -0,0 +1,15 @@ +using Volo.Abp.Collections; + +namespace Volo.Abp.SimpleStateChecking +{ + public class AbpSimpleStateCheckerOptions + where TState : IHasSimpleStateCheckers + { + public ITypeList> GlobalStateCheckers { get; } + + public AbpSimpleStateCheckerOptions() + { + GlobalStateCheckers = new TypeList>(); + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/IHasSimpleStateCheckers.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/IHasSimpleStateCheckers.cs new file mode 100644 index 0000000000..b9548e3bf4 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/IHasSimpleStateCheckers.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace Volo.Abp.SimpleStateChecking +{ + public interface IHasSimpleStateCheckers + where TState : IHasSimpleStateCheckers + { + List> StateCheckers { get; } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleBatchStateChecker.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleBatchStateChecker.cs new file mode 100644 index 0000000000..ff364ff223 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleBatchStateChecker.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.SimpleStateChecking +{ + public interface ISimpleBatchStateChecker : ISimpleStateChecker + where TState : IHasSimpleStateCheckers + { + Task> IsEnabledAsync(SimpleBatchStateCheckerContext context); + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateChecker.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateChecker.cs new file mode 100644 index 0000000000..6d50044520 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateChecker.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.SimpleStateChecking +{ + public interface ISimpleStateChecker + where TState : IHasSimpleStateCheckers + { + Task IsEnabledAsync(SimpleStateCheckerContext context); + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerManager.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerManager.cs new file mode 100644 index 0000000000..4ea98f7e68 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerManager.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.SimpleStateChecking +{ + public interface ISimpleStateCheckerManager + where TState : IHasSimpleStateCheckers + { + Task IsEnabledAsync(TState state); + + Task> IsEnabledAsync(TState[] states); + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerBase.cs new file mode 100644 index 0000000000..43b2e2a6fe --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerBase.cs @@ -0,0 +1,16 @@ +using System.Linq; +using System.Threading.Tasks; + +namespace Volo.Abp.SimpleStateChecking +{ + public abstract class SimpleBatchStateCheckerBase: ISimpleBatchStateChecker + where TState : IHasSimpleStateCheckers + { + public async Task IsEnabledAsync(SimpleStateCheckerContext context) + { + return (await IsEnabledAsync(new SimpleBatchStateCheckerContext(context.ServiceProvider, new[] {context.State}))).Values.All(x => x); + } + + public abstract Task> IsEnabledAsync(SimpleBatchStateCheckerContext context); + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerContext.cs new file mode 100644 index 0000000000..ae5826a3e1 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleBatchStateCheckerContext.cs @@ -0,0 +1,18 @@ +using System; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleBatchStateCheckerContext + where TState : IHasSimpleStateCheckers + { + public IServiceProvider ServiceProvider { get; } + + public TState[] States { get; } + + public SimpleBatchStateCheckerContext(IServiceProvider serviceProvider, TState[] states) + { + ServiceProvider = serviceProvider; + States = states; + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerContext.cs new file mode 100644 index 0000000000..04e9da4720 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerContext.cs @@ -0,0 +1,18 @@ +using System; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateCheckerContext + where TState : IHasSimpleStateCheckers + { + public IServiceProvider ServiceProvider { get; } + + public TState State { get; } + + public SimpleStateCheckerContext(IServiceProvider serviceProvider, TState state) + { + ServiceProvider = serviceProvider; + State = state; + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerManager.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerManager.cs new file mode 100644 index 0000000000..61a252850d --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerManager.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateCheckerManager : ISimpleStateCheckerManager + where TState : IHasSimpleStateCheckers + { + protected IServiceProvider ServiceProvider { get; } + + protected AbpSimpleStateCheckerOptions Options { get; } + + public SimpleStateCheckerManager(IServiceProvider serviceProvider, IOptions> options) + { + ServiceProvider = serviceProvider; + Options = options.Value; + } + + public virtual async Task IsEnabledAsync(TState state) + { + return await InternalIsEnabledAsync(state, true); + } + + public virtual async Task> IsEnabledAsync(TState[] states) + { + var result = new SimpleStateCheckerResult(states); + + using (var scope = ServiceProvider.CreateScope()) + { + var batchStateCheckers = states.SelectMany(x => x.StateCheckers) + .Where(x => x is ISimpleBatchStateChecker) + .Cast>() + .GroupBy(x => x) + .Select(x => x.Key); + + foreach (var stateChecker in batchStateCheckers) + { + var context = new SimpleBatchStateCheckerContext( + scope.ServiceProvider.GetRequiredService(), + states.Where(x => x.StateCheckers.Contains(stateChecker)).ToArray()); + + foreach (var x in await stateChecker.IsEnabledAsync(context)) + { + result[x.Key] = x.Value; + } + + if (result.Values.All(x => !x)) + { + return result; + } + } + + foreach (ISimpleBatchStateChecker globalStateChecker in Options.GlobalStateCheckers + .Where(x => typeof(ISimpleBatchStateChecker).IsAssignableFrom(x)) + .Select(x => ServiceProvider.GetRequiredService(x))) + { + var context = new SimpleBatchStateCheckerContext( + scope.ServiceProvider.GetRequiredService(), + states.Where(x => result.Any(y => y.Key.Equals(x) && y.Value)).ToArray()); + + foreach (var x in await globalStateChecker.IsEnabledAsync(context)) + { + result[x.Key] = x.Value; + } + } + + foreach (var state in states) + { + if (result[state]) + { + result[state] = await InternalIsEnabledAsync(state, false); + } + } + + return result; + } + } + + protected virtual async Task InternalIsEnabledAsync(TState state, bool useBatchChecker) + { + using (var scope = ServiceProvider.CreateScope()) + { + var context = new SimpleStateCheckerContext(scope.ServiceProvider.GetRequiredService(), state); + + foreach (var provider in state.StateCheckers.WhereIf(!useBatchChecker, x => x is not ISimpleBatchStateChecker)) + { + if (!await provider.IsEnabledAsync(context)) + { + return false; + } + } + + foreach (ISimpleStateChecker provider in Options.GlobalStateCheckers + .WhereIf(!useBatchChecker, x => !typeof(ISimpleBatchStateChecker).IsAssignableFrom(x)) + .Select(x => ServiceProvider.GetRequiredService(x))) + { + if (!await provider.IsEnabledAsync(context)) + { + return false; + } + } + + return true; + } + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerResult.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerResult.cs new file mode 100644 index 0000000000..a3c1dc8020 --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerResult.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateCheckerResult : Dictionary + where TState : IHasSimpleStateCheckers + { + public SimpleStateCheckerResult() + { + + } + + public SimpleStateCheckerResult(IEnumerable states, bool initValue = true) + { + foreach (var state in states) + { + Add(state, initValue); + } + } + } +} diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolverExtensions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolverExtensions.cs index 1fa097964c..ceeaec8f8f 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolverExtensions.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolverExtensions.cs @@ -10,13 +10,26 @@ namespace Volo.Abp.Data [Obsolete("Use ResolveAsync method")] public static string Resolve(this IConnectionStringResolver resolver) { - return resolver.Resolve(ConnectionStringNameAttribute.GetConnStringName()); + return resolver.Resolve(typeof(T)); } [NotNull] public static Task ResolveAsync(this IConnectionStringResolver resolver) { - return resolver.ResolveAsync(ConnectionStringNameAttribute.GetConnStringName()); + return resolver.ResolveAsync(typeof(T)); + } + + [NotNull] + [Obsolete("Use ResolveAsync method")] + public static string Resolve(this IConnectionStringResolver resolver, Type type) + { + return resolver.Resolve(ConnectionStringNameAttribute.GetConnStringName(type)); + } + + [NotNull] + public static Task ResolveAsync(this IConnectionStringResolver resolver, Type type) + { + return resolver.ResolveAsync(ConnectionStringNameAttribute.GetConnStringName(type)); } } } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs index 92c6935900..75dd6a5dc4 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs @@ -39,6 +39,11 @@ namespace Volo.Abp.EntityFrameworkCore DefaultConfigureAction = action; } + public bool IsConfiguredDefault() + { + return DefaultConfigureAction != null; + } + public void PreConfigure([NotNull] Action> action) where TDbContext : AbpDbContext { @@ -60,6 +65,16 @@ namespace Volo.Abp.EntityFrameworkCore ConfigureActions[typeof(TDbContext)] = action; } + + public bool IsConfigured() + { + return IsConfigured(typeof(TDbContext)); + } + + public bool IsConfigured(Type dbContextType) + { + return ConfigureActions.ContainsKey(dbContextType); + } internal Type GetReplacedTypeOrSelf(Type dbContextType) { diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs index 2fa56b550b..e5e4c2584a 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs @@ -62,10 +62,9 @@ namespace Volo.Abp.Uow.EntityFrameworkCore throw new AbpException("A DbContext can only be created inside a unit of work!"); } - var connectionStringName = ConnectionStringNameAttribute.GetConnStringName(); - var connectionString = ResolveConnectionString(connectionStringName); - var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TDbContext)); + var connectionStringName = ConnectionStringNameAttribute.GetConnStringName(targetDbContextType); + var connectionString = ResolveConnectionString(connectionStringName); var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}"; var databaseApi = unitOfWork.GetOrAddDatabaseApi( @@ -85,10 +84,10 @@ namespace Volo.Abp.Uow.EntityFrameworkCore throw new AbpException("A DbContext can only be created inside a unit of work!"); } - var connectionStringName = ConnectionStringNameAttribute.GetConnStringName(); + var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TDbContext)); + var connectionStringName = ConnectionStringNameAttribute.GetConnStringName(targetDbContextType); var connectionString = await ResolveConnectionStringAsync(connectionStringName); - var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TDbContext)); var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}"; var databaseApi = unitOfWork.FindDatabaseApi(dbContextKey); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureSimpleStateCheckerExtensions.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureSimpleStateCheckerExtensions.cs new file mode 100644 index 0000000000..d06e55effa --- /dev/null +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureSimpleStateCheckerExtensions.cs @@ -0,0 +1,30 @@ +using JetBrains.Annotations; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Features +{ + public static class FeatureSimpleStateCheckerExtensions + { + public static TState RequireFeatures( + [NotNull] this TState state, + params string[] features) + where TState : IHasSimpleStateCheckers + { + state.RequireFeatures(true, features); + return state; + } + + public static TState RequireFeatures( + [NotNull] this TState state, + bool requiresAll, + params string[] features) + where TState : IHasSimpleStateCheckers + { + Check.NotNull(state, nameof(state)); + Check.NotNullOrEmpty(features, nameof(features)); + + state.StateCheckers.Add(new RequireFeaturesSimpleStateChecker(requiresAll, features)); + return state; + } + } +} diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/PermissionDefinitionExtensions.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/PermissionDefinitionExtensions.cs deleted file mode 100644 index a213232f2f..0000000000 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/PermissionDefinitionExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JetBrains.Annotations; -using Volo.Abp.Authorization.Permissions; - -namespace Volo.Abp.Features -{ - public static class FeatureDefinitionExtensions - { - public static PermissionDefinition RequireFeatures( - [NotNull] this PermissionDefinition permissionDefinition, - params string[] features) - { - return permissionDefinition.RequireFeatures(true, features); - } - - public static PermissionDefinition RequireFeatures( - [NotNull] this PermissionDefinition permissionDefinition, - bool requiresAll, - params string[] features) - { - Check.NotNull(permissionDefinition, nameof(permissionDefinition)); - Check.NotNullOrEmpty(features, nameof(features)); - - return permissionDefinition.AddStateProviders( - new RequireFeaturesPermissionStateProvider(requiresAll, features) - ); - } - } -} diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesPermissionStateProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesPermissionStateProvider.cs deleted file mode 100644 index 0fee54c598..0000000000 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesPermissionStateProvider.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Authorization.Permissions; - -namespace Volo.Abp.Features -{ - public class RequireFeaturesPermissionStateProvider : IPermissionStateProvider - { - private readonly string[] _featureNames; - private readonly bool _requiresAll; - - public RequireFeaturesPermissionStateProvider(params string[] featureNames) - : this(true, featureNames) - { - - } - - public RequireFeaturesPermissionStateProvider(bool requiresAll, params string[] featureNames) - { - Check.NotNullOrEmpty(featureNames, nameof(featureNames)); - - _requiresAll = requiresAll; - _featureNames = featureNames; - } - - public async Task IsEnabledAsync(PermissionStateContext context) - { - var feature = context.ServiceProvider.GetRequiredService(); - return await feature.IsEnabledAsync(_requiresAll, _featureNames); - } - } -} diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesSimpleStateChecker.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesSimpleStateChecker.cs new file mode 100644 index 0000000000..1a4c028653 --- /dev/null +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/RequireFeaturesSimpleStateChecker.cs @@ -0,0 +1,32 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.Features +{ + public class RequireFeaturesSimpleStateChecker : ISimpleStateChecker + where TState : IHasSimpleStateCheckers + { + private readonly string[] _featureNames; + private readonly bool _requiresAll; + + public RequireFeaturesSimpleStateChecker(params string[] featureNames) + : this(true, featureNames) + { + } + + public RequireFeaturesSimpleStateChecker(bool requiresAll, params string[] featureNames) + { + Check.NotNullOrEmpty(featureNames, nameof(featureNames)); + + _requiresAll = requiresAll; + _featureNames = featureNames; + } + + public async Task IsEnabledAsync(SimpleStateCheckerContext context) + { + var featureChecker = context.ServiceProvider.GetRequiredService(); + return await featureChecker.IsEnabledAsync(_requiresAll, _featureNames); + } + } +} diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureDefinitionExtensions.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureDefinitionExtensions.cs deleted file mode 100644 index 299994e695..0000000000 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureDefinitionExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using JetBrains.Annotations; -using Volo.Abp.Authorization.Permissions; - -namespace Volo.Abp.GlobalFeatures -{ - public static class GlobalFeatureDefinitionExtensions - { - public static PermissionDefinition RequireGlobalFeatures( - this PermissionDefinition permissionDefinition, - params string[] globalFeatures) - { - return permissionDefinition.RequireGlobalFeatures(true, globalFeatures); - } - - public static PermissionDefinition RequireGlobalFeatures( - [NotNull] this PermissionDefinition permissionDefinition, - bool requiresAll, - params string[] globalFeatures) - { - Check.NotNull(permissionDefinition, nameof(permissionDefinition)); - Check.NotNullOrEmpty(globalFeatures, nameof(globalFeatures)); - - return permissionDefinition.AddStateProviders( - new RequireGlobalFeaturesPermissionStateProvider(requiresAll, globalFeatures) - ); - } - - public static PermissionDefinition RequireGlobalFeatures( - this PermissionDefinition permissionDefinition, - params Type[] globalFeatures) - { - return permissionDefinition.RequireGlobalFeatures(true, globalFeatures); - } - - public static PermissionDefinition RequireGlobalFeatures( - [NotNull] this PermissionDefinition permissionDefinition, - bool requiresAll, - params Type[] globalFeatures) - { - Check.NotNull(permissionDefinition, nameof(permissionDefinition)); - Check.NotNullOrEmpty(globalFeatures, nameof(globalFeatures)); - - return permissionDefinition.AddStateProviders( - new RequireGlobalFeaturesPermissionStateProvider(requiresAll, globalFeatures) - ); - } - - } -} diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureSimpleStateCheckerExtensions.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureSimpleStateCheckerExtensions.cs new file mode 100644 index 0000000000..f18f3d1569 --- /dev/null +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureSimpleStateCheckerExtensions.cs @@ -0,0 +1,51 @@ +using System; +using JetBrains.Annotations; +using Volo.Abp.SimpleStateChecking; + +namespace Volo.Abp.GlobalFeatures +{ + public static class GlobalFeatureSimpleStateCheckerExtensions + { + public static TState RequireGlobalFeatures( + [NotNull] this TState state, + params string[] globalFeatures) + where TState : IHasSimpleStateCheckers + { + return state.RequireGlobalFeatures(true, globalFeatures); + } + + public static TState RequireGlobalFeatures( + [NotNull] this TState state, + bool requiresAll, + params string[] globalFeatures) + where TState : IHasSimpleStateCheckers + { + Check.NotNull(state, nameof(state)); + Check.NotNullOrEmpty(globalFeatures, nameof(globalFeatures)); + + state.StateCheckers.Add(new RequireGlobalFeaturesSimpleStateChecker(requiresAll, globalFeatures)); + return state; + } + + public static TState RequireGlobalFeatures( + [NotNull] this TState state, + params Type[] globalFeatures) + where TState : IHasSimpleStateCheckers + { + return state.RequireGlobalFeatures(true, globalFeatures); + } + + public static TState RequireGlobalFeatures( + [NotNull] this TState state, + bool requiresAll, + params Type[] globalFeatures) + where TState : IHasSimpleStateCheckers + { + Check.NotNull(state, nameof(state)); + Check.NotNullOrEmpty(globalFeatures, nameof(globalFeatures)); + + state.StateCheckers.Add(new RequireGlobalFeaturesSimpleStateChecker(requiresAll, globalFeatures)); + return state; + } + } +} diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesPermissionStateProvider.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesSimpleStateChecker.cs similarity index 61% rename from framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesPermissionStateProvider.cs rename to framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesSimpleStateChecker.cs index c96e652e8c..12754d87df 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesPermissionStateProvider.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequireGlobalFeaturesSimpleStateChecker.cs @@ -1,21 +1,22 @@ using System; using System.Linq; using System.Threading.Tasks; -using Volo.Abp.Authorization.Permissions; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.GlobalFeatures { - public class RequireGlobalFeaturesPermissionStateProvider : IPermissionStateProvider + public class RequireGlobalFeaturesSimpleStateChecker : ISimpleStateChecker + where TState : IHasSimpleStateCheckers { private readonly string[] _globalFeatureNames; private readonly bool _requiresAll; - public RequireGlobalFeaturesPermissionStateProvider(params string[] globalFeatureNames) + public RequireGlobalFeaturesSimpleStateChecker(params string[] globalFeatureNames) : this(true, globalFeatureNames) { } - public RequireGlobalFeaturesPermissionStateProvider(bool requiresAll, params string[] globalFeatureNames) + public RequireGlobalFeaturesSimpleStateChecker(bool requiresAll, params string[] globalFeatureNames) { Check.NotNullOrEmpty(globalFeatureNames, nameof(globalFeatureNames)); @@ -23,7 +24,7 @@ namespace Volo.Abp.GlobalFeatures _globalFeatureNames = globalFeatureNames; } - public RequireGlobalFeaturesPermissionStateProvider(bool requiresAll, params Type[] globalFeatureNames) + public RequireGlobalFeaturesSimpleStateChecker(bool requiresAll, params Type[] globalFeatureNames) { Check.NotNullOrEmpty(globalFeatureNames, nameof(globalFeatureNames)); @@ -31,9 +32,9 @@ namespace Volo.Abp.GlobalFeatures _globalFeatureNames = globalFeatureNames.Select(GlobalFeatureNameAttribute.GetName).ToArray(); } - public Task IsEnabledAsync(PermissionStateContext context) + public Task IsEnabledAsync(SimpleStateCheckerContext context) { - bool isEnabled = _requiresAll + var isEnabled = _requiresAll ? _globalFeatureNames.All(x => GlobalFeatureManager.Instance.IsEnabled(x)) : _globalFeatureNames.Any(x => GlobalFeatureManager.Instance.IsEnabled(x)); diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs index c86fc095c7..3f74918d98 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs @@ -1,6 +1,9 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using IdentityModel.Client; +using JetBrains.Annotations; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.IdentityModel; @@ -8,16 +11,18 @@ using Volo.Abp.IdentityModel; namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly { [Dependency(ReplaceServices = true)] - public class AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator : IdentityModelRemoteServiceHttpClientAuthenticator + public class AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator + : IdentityModelRemoteServiceHttpClientAuthenticator { + [CanBeNull] protected IAccessTokenProvider AccessTokenProvider { get; } public AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator( IIdentityModelAuthenticationService identityModelAuthenticationService, - IAccessTokenProvider accessTokenProvider) + IServiceProvider serviceProvider) : base(identityModelAuthenticationService) { - AccessTokenProvider = accessTokenProvider; + AccessTokenProvider = serviceProvider.GetService(); } public override async Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) @@ -37,6 +42,11 @@ namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly protected virtual async Task GetAccessTokenFromAccessTokenProviderOrNullAsync() { + if (AccessTokenProvider == null) + { + return null; + } + var result = await AccessTokenProvider.RequestAccessToken(); if (result.Status != AccessTokenResultStatus.Success) { diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs index a26307234d..2a3842441f 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs @@ -62,8 +62,8 @@ namespace Volo.Abp.Uow.MongoDB $"A {nameof(IMongoDatabase)} instance can only be created inside a unit of work!"); } - var connectionString = ResolveConnectionString(); var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TMongoDbContext)); + var connectionString = ResolveConnectionString(targetDbContextType); var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}"; var mongoUrl = new MongoUrl(connectionString); @@ -90,8 +90,8 @@ namespace Volo.Abp.Uow.MongoDB $"A {nameof(IMongoDatabase)} instance can only be created inside a unit of work!"); } - var connectionString = await ResolveConnectionStringAsync(); var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TMongoDbContext)); + var connectionString = await ResolveConnectionStringAsync(targetDbContextType); var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}"; var mongoUrl = new MongoUrl(connectionString); @@ -244,33 +244,33 @@ namespace Volo.Abp.Uow.MongoDB return dbContext; } - private async Task ResolveConnectionStringAsync() + private async Task ResolveConnectionStringAsync(Type dbContextType) { // Multi-tenancy unaware contexts should always use the host connection string if (typeof(TMongoDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false)) { using (_currentTenant.Change(null)) { - return await _connectionStringResolver.ResolveAsync(); + return await _connectionStringResolver.ResolveAsync(dbContextType); } } - return await _connectionStringResolver.ResolveAsync(); + return await _connectionStringResolver.ResolveAsync(dbContextType); } [Obsolete("Use ResolveConnectionStringAsync method.")] - private string ResolveConnectionString() + private string ResolveConnectionString(Type dbContextType) { // Multi-tenancy unaware contexts should always use the host connection string if (typeof(TMongoDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false)) { using (_currentTenant.Change(null)) { - return _connectionStringResolver.Resolve(); + return _connectionStringResolver.Resolve(dbContextType); } } - return _connectionStringResolver.Resolve(); + return _connectionStringResolver.Resolve(dbContextType); } protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default) diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfiguration.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfiguration.cs index e586e687c3..35b3a0e52e 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfiguration.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfiguration.cs @@ -13,12 +13,15 @@ namespace Volo.Abp.MultiTenancy public ConnectionStrings ConnectionStrings { get; set; } + public bool IsActive { get; set; } + public TenantConfiguration() { - + IsActive = true; } public TenantConfiguration(Guid id, [NotNull] string name) + : this() { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs index 81a9c72042..1c3223828d 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs @@ -42,6 +42,15 @@ namespace Volo.Abp.MultiTenancy details: "There is no tenant with the tenant id or name: " + resolveResult.TenantIdOrName ); } + + if (!tenant.IsActive) + { + throw new BusinessException( + code: "Volo.AbpIo.MultiTenancy:010002", + message: "Tenant not active!", + details: "The tenant is no active with the tenant id or name: " + resolveResult.TenantIdOrName + ); + } } return tenant; diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs index d54ee7104a..237953db4a 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using JetBrains.Annotations; using Volo.Abp.Data; @@ -68,7 +69,9 @@ namespace Volo.Abp.ObjectExtending [NotNull] public virtual ImmutableList GetProperties() { - return Properties.Values.ToImmutableList(); + return Properties.OrderBy(t=>t.Key) + .Select(t=>t.Value) + .ToImmutableList(); } [CanBeNull] diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs index 63f4d7239d..f269c34598 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.UI.Navigation { - public class ApplicationMenuItem : IHasMenuItems + public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers { private string _displayName; @@ -72,8 +73,11 @@ namespace Volo.Abp.UI.Navigation public ApplicationMenuItemList Items { get; } [CanBeNull] + [Obsolete("Use RequirePermissions extension method.")] public string RequiredPermissionName { get; set; } + public List> StateCheckers { get; } + /// /// Can be used to store a custom object related to this menu item. Optional. /// @@ -114,7 +118,7 @@ namespace Volo.Abp.UI.Navigation ElementId = elementId ?? GetDefaultElementId(); CssClass = cssClass; RequiredPermissionName = requiredPermissionName; - + StateCheckers = new List>(); Items = new ApplicationMenuItemList(); } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs index 960389230e..fe5c5da242 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.Authorization.Permissions; using Volo.Abp.DependencyInjection; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.UI.Navigation { @@ -13,13 +13,16 @@ namespace Volo.Abp.UI.Navigation { protected AbpNavigationOptions Options { get; } protected IHybridServiceScopeFactory ServiceScopeFactory { get; } + protected ISimpleStateCheckerManager SimpleStateCheckerManager { get; } public MenuManager( IOptions options, - IHybridServiceScopeFactory serviceScopeFactory) + IHybridServiceScopeFactory serviceScopeFactory, + ISimpleStateCheckerManager simpleStateCheckerManager) { - ServiceScopeFactory = serviceScopeFactory; Options = options.Value; + ServiceScopeFactory = serviceScopeFactory; + SimpleStateCheckerManager = simpleStateCheckerManager; } public async Task GetAsync(string name) @@ -45,18 +48,26 @@ namespace Volo.Abp.UI.Navigation protected virtual async Task CheckPermissionsAsync(IServiceProvider serviceProvider, IHasMenuItems menuWithItems) { - var requiredPermissionItems = new List(); - GetRequiredPermissionNameMenus(menuWithItems, requiredPermissionItems); + var allMenuItems = new List(); + GetAllMenuItems(menuWithItems, allMenuItems); - if (requiredPermissionItems.Any()) + foreach (var item in allMenuItems) { - var permissionChecker = serviceProvider.GetRequiredService(); - var grantResult = await permissionChecker.IsGrantedAsync(requiredPermissionItems.Select(x => x.RequiredPermissionName).Distinct().ToArray()); + if (!item.RequiredPermissionName.IsNullOrWhiteSpace()) + { + item.RequirePermissions(item.RequiredPermissionName); + } + } + var checkPermissionsMenuItems = allMenuItems.Where(x => x.StateCheckers.Any()).ToArray(); + + if (checkPermissionsMenuItems.Any()) + { var toBeDeleted = new HashSet(); - foreach (var menu in requiredPermissionItems) + var result = await SimpleStateCheckerManager.IsEnabledAsync(checkPermissionsMenuItems); + foreach (var menu in checkPermissionsMenuItems) { - if (grantResult.Result[menu.RequiredPermissionName!] != PermissionGrantResult.Granted) + if (!result[menu]) { toBeDeleted.Add(menu); } @@ -66,16 +77,12 @@ namespace Volo.Abp.UI.Navigation } } - protected virtual void GetRequiredPermissionNameMenus(IHasMenuItems menuWithItems, List output) + protected virtual void GetAllMenuItems(IHasMenuItems menuWithItems, List output) { foreach (var item in menuWithItems.Items) { - if (!item.RequiredPermissionName.IsNullOrWhiteSpace()) - { - output.Add(item); - } - - GetRequiredPermissionNameMenus(item, output); + output.Add(item); + GetAllMenuItems(item, output); } } diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/es.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/es.json index 076d4b2517..ff846b3f18 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/es.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/es.json @@ -11,7 +11,7 @@ "Close": "Cerrar", "Save": "Guardar", "SavingWithThreeDot": "Guardando...", - "Actions": "Acciones", + "Actions": "Opciones", "Delete": "Borrar", "Edit": "Editar", "Refresh": "Actualizar", @@ -20,10 +20,10 @@ "ProcessingWithThreeDot": "Procesando...", "LoadingWithThreeDot": "Cargardo...", "Welcome": "Bienvenido", - "Login": "Iniciar Sesión", + "Login": "Iniciar sesión", "Register": "Registrarse", "Logout": "Cerrar sesión", - "Submit": "Enviar", + "Submit": "Guardar", "Back": "Volver", "PagerSearch": "Buscar", "PagerNext": "Siguiente", @@ -37,11 +37,11 @@ "NoDataAvailableInDatatable": "No hay datos disponibles", "Total": "Total", "Selected": "Seleccionado", - "PagerShowMenuEntries": "Mostrar _MENU_ entradas", - "DatatableActionDropdownDefaultText": "Acciones", + "PagerShowMenuEntries": "Mostrar _MENU_ registros", + "DatatableActionDropdownDefaultText": "Opciones", "ChangePassword": "Cambiar contraseña", "PersonalInfo": "Mi perfil", - "AreYouSureYouWantToCancelEditingWarningMessage": "Tu tienes cambios sin guardar", + "AreYouSureYouWantToCancelEditingWarningMessage": "Tienes cambios sin guardar", "GoHomePage": "Ir a la página principal", "GoBack": "Volver atrás", "Search": "Buscar", diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests/Volo/Abp/AspNetCore/Mvc/UI/Theme/Shared/Toolbars/Toolbar_Tests.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests/Volo/Abp/AspNetCore/Mvc/UI/Theme/Shared/Toolbars/Toolbar_Tests.cs index 70ca907fac..928a2af8de 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests/Volo/Abp/AspNetCore/Mvc/UI/Theme/Shared/Toolbars/Toolbar_Tests.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests/Volo/Abp/AspNetCore/Mvc/UI/Theme/Shared/Toolbars/Toolbar_Tests.cs @@ -11,6 +11,7 @@ using NSubstitute; using Shouldly; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theming; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Security.Claims; using Xunit; @@ -71,8 +72,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests.Volo.Abp.AspNetCore.Mvc. return Task.CompletedTask; } - context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent1), requiredPermissionName: "MyComponent1")); - context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent2), requiredPermissionName: "MyComponent2")); + context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent1)).RequirePermissions("MyComponent1")); + context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent2)).RequirePermissions("MyComponent2")); return Task.CompletedTask; } @@ -87,7 +88,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests.Volo.Abp.AspNetCore.Mvc. return Task.CompletedTask; } - context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent3), requiredPermissionName: "MyComponent3")); + context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent3)).RequirePermissions("MyComponent3")); context.Toolbar.Items.Add(new ToolbarItem(typeof(MyComponent4))); return Task.CompletedTask; diff --git a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/PermissionStateProvider_Tests.cs b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/PermissionStateProvider_Tests.cs index f7ab858ac1..43dfa11330 100644 --- a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/PermissionStateProvider_Tests.cs +++ b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/PermissionStateProvider_Tests.cs @@ -5,19 +5,20 @@ using Microsoft.Extensions.DependencyInjection; using Shouldly; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Security.Claims; +using Volo.Abp.SimpleStateChecking; using Xunit; namespace Volo.Abp.Authorization { public abstract class PermissionStateProvider_Tests : AuthorizationTestBase { - protected IPermissionStateManager PermissionStateManager { get; } + protected ISimpleStateCheckerManager StateCheckerManager { get; } protected IPermissionDefinitionManager PermissionDefinitionManager { get; } protected ICurrentPrincipalAccessor CurrentPrincipalAccessor { get; } public PermissionStateProvider_Tests() { - PermissionStateManager = GetRequiredService(); + StateCheckerManager = GetRequiredService>(); PermissionDefinitionManager = GetRequiredService(); CurrentPrincipalAccessor = GetRequiredService(); } @@ -29,13 +30,13 @@ namespace Volo.Abp.Authorization public async Task PermissionState_Test() { var myPermission1 = PermissionDefinitionManager.Get("MyPermission1"); - myPermission1.StateProviders.ShouldContain(x => x.GetType() == typeof(TestRequireEditionPermissionStateProvider)); + myPermission1.StateCheckers.ShouldContain(x => x.GetType() == typeof(TestRequireEditionPermissionSimpleStateChecker)); - (await PermissionStateManager.IsEnabledAsync(myPermission1)).ShouldBeFalse(); + (await StateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeFalse(); using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.EditionId, Guid.NewGuid().ToString()))) { - (await PermissionStateManager.IsEnabledAsync(myPermission1)).ShouldBeTrue(); + (await StateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeTrue(); } } } @@ -44,7 +45,10 @@ namespace Volo.Abp.Authorization { protected override void AfterAddApplication(IServiceCollection services) { - services.Configure(options => options.GlobalStateProviders.Add()); + services.Configure>(options => + { + options.GlobalStateCheckers.Add(); + }); } [Fact] @@ -52,11 +56,11 @@ namespace Volo.Abp.Authorization { var myPermission2 = PermissionDefinitionManager.Get("MyPermission2"); - (await PermissionStateManager.IsEnabledAsync(myPermission2)).ShouldBeFalse(); + (await StateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeFalse(); using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.Role, "admin"))) { - (await PermissionStateManager.IsEnabledAsync(myPermission2)).ShouldBeTrue(); + (await StateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeTrue(); } } } diff --git a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionStateProvider.cs b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionSimpleStateChecker.cs similarity index 65% rename from framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionStateProvider.cs rename to framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionSimpleStateChecker.cs index 6e3b58d2de..78726a343d 100644 --- a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionStateProvider.cs +++ b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestGlobalRequireRolePermissionSimpleStateChecker.cs @@ -3,12 +3,13 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Authorization.Permissions; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.Authorization { - public class TestGlobalRequireRolePermissionStateProvider : IPermissionStateProvider, ITransientDependency + public class TestGlobalRequireRolePermissionSimpleStateChecker : ISimpleStateChecker, ITransientDependency { - public Task IsEnabledAsync(PermissionStateContext context) + public Task IsEnabledAsync(SimpleStateCheckerContext context) { var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService(); return Task.FromResult(currentPrincipalAccessor.Principal != null && currentPrincipalAccessor.Principal.IsInRole("admin")); diff --git a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionStateProvider.cs b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionSimpleStateChecker.cs similarity index 66% rename from framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionStateProvider.cs rename to framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionSimpleStateChecker.cs index a793c84431..8ce5ab9523 100644 --- a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionStateProvider.cs +++ b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestRequireEditionPermissionSimpleStateChecker.cs @@ -3,12 +3,13 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Security.Claims; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.Authorization { - public class TestRequireEditionPermissionStateProvider : IPermissionStateProvider + public class TestRequireEditionPermissionSimpleStateChecker : ISimpleStateChecker { - public Task IsEnabledAsync(PermissionStateContext context) + public Task IsEnabledAsync(SimpleStateCheckerContext context) { var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService(); return Task.FromResult(currentPrincipalAccessor.Principal?.FindEditionId() != null); diff --git a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestServices/AuthorizationTestPermissionDefinitionProvider.cs b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestServices/AuthorizationTestPermissionDefinitionProvider.cs index d67cf8febc..6f284d7029 100644 --- a/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestServices/AuthorizationTestPermissionDefinitionProvider.cs +++ b/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestServices/AuthorizationTestPermissionDefinitionProvider.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.Authorization.TestServices group.AddPermission("MyAuthorizedService1"); - group.AddPermission("MyPermission1").AddStateProviders(new TestRequireEditionPermissionStateProvider()); + group.AddPermission("MyPermission1").StateCheckers.Add(new TestRequireEditionPermissionSimpleStateChecker()); group.AddPermission("MyPermission2"); group.GetPermissionOrNull("MyAuthorizedService1").ShouldNotBeNull(); diff --git a/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs index c8d31990cf..36174f1004 100644 --- a/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs +++ b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs @@ -64,5 +64,26 @@ namespace Volo.Abp.Cli commandLineArgs.Options.ShouldContainKey("optionC"); commandLineArgs.Options["optionC"].ShouldBe("value2"); } + + [Fact] + public void Should_Parse_From_Line_Text() + { + var commandLineArgs = _commandLineArgumentParser.Parse( + "mycommand mytarget -a value1 -b \"value with space\" --optionC" + ); + + commandLineArgs.Command.ShouldBe("mycommand"); + commandLineArgs.Target.ShouldBe("mytarget"); + commandLineArgs.Options.Any().ShouldBeTrue(); + + commandLineArgs.Options.ShouldContainKey("a"); + commandLineArgs.Options["a"].ShouldBe("value1"); + + commandLineArgs.Options.ShouldContainKey("b"); + commandLineArgs.Options["b"].ShouldBe("value with space"); + + commandLineArgs.Options.ShouldContainKey("optionC"); + commandLineArgs.Options["optionC"].ShouldBeNull(); + } } } diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/AbpTestModule.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/AbpTestModule.cs new file mode 100644 index 0000000000..b42ff1e6e8 --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/AbpTestModule.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp +{ + public class AbpTestModule : AbpModule + { + + } +} diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateCheckerTestBase.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateCheckerTestBase.cs new file mode 100644 index 0000000000..2debf8a66b --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateCheckerTestBase.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Testing; + +namespace Volo.Abp.SimpleStateChecking +{ + public abstract class SimpleStateCheckerTestBase : AbpIntegratedTest + { + protected readonly ISimpleStateCheckerManager SimpleStateCheckerManager; + + public SimpleStateCheckerTestBase() + { + SimpleStateCheckerManager = GetRequiredService>(); + } + + public class MyStateEntity : IHasSimpleStateCheckers + { + public int CheckCount { get; set; } + + public int GlobalCheckCount { get; set; } + + public int MultipleCheckCount { get; set; } + + public int MultipleGlobalCheckCount { get; set; } + + public DateTime CreationTime { get; set; } + + public DateTime? LastModificationTime { get; set; } + + public List> StateCheckers { get; } + + public MyStateEntity() + { + StateCheckers = new List>(); + } + + public MyStateEntity AddSimpleStateChecker(ISimpleStateChecker checker) + { + StateCheckers.Add(checker); + return this; + } + } + + public class MySimpleStateChecker : ISimpleStateChecker + { + public Task IsEnabledAsync(SimpleStateCheckerContext context) + { + context.State.CheckCount += 1; + return Task.FromResult(context.State.CreationTime > DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture)); + } + } + + public class MyGlobalSimpleStateChecker : ISimpleStateChecker, ITransientDependency + { + public Task IsEnabledAsync(SimpleStateCheckerContext context) + { + context.State.GlobalCheckCount += 1; + return Task.FromResult(context.State.LastModificationTime.HasValue); + } + } + + public class MySimpleBatchStateChecker : SimpleBatchStateCheckerBase + { + public override Task> IsEnabledAsync(SimpleBatchStateCheckerContext context) + { + foreach (var state in context.States) + { + state.MultipleCheckCount += 1; + } + + var result = new SimpleStateCheckerResult(context.States); + + foreach (var x in result) + { + result[x.Key] = x.Key.CreationTime > DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture); + } + + return Task.FromResult(result); + } + } + + public class MyGlobalSimpleBatchStateChecker : SimpleBatchStateCheckerBase, ITransientDependency + { + public override Task> IsEnabledAsync(SimpleBatchStateCheckerContext context) + { + foreach (var state in context.States) + { + state.MultipleGlobalCheckCount += 1; + } + + var result = new SimpleStateCheckerResult(context.States); + + foreach (var x in result) + { + result[x.Key] = x.Key.LastModificationTime.HasValue; + } + + return Task.FromResult(result); + } + } + } +} diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_CheckCount_Test.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_CheckCount_Test.cs new file mode 100644 index 0000000000..ff7f320bb3 --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_CheckCount_Test.cs @@ -0,0 +1,81 @@ +using System; +using System.Globalization; +using System.Threading.Tasks; +using Shouldly; +using Xunit; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateChecker_CheckCount_Test : SimpleStateCheckerTestBase + { + [Fact] + public async Task Simple_State_Check_Should_Be_Prevent_Multiple_Checks() + { + var myStateEntities = new SimpleStateCheckerTestBase.MyStateEntity[] + { + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture) + }, + + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture), + } + }; + + myStateEntities[0].AddSimpleStateChecker(new MySimpleBatchStateChecker()); + myStateEntities[1].AddSimpleStateChecker(new MySimpleStateChecker()); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities[0])).ShouldBeTrue(); + + myStateEntities[0].CheckCount.ShouldBe(0); + myStateEntities[0].GlobalCheckCount.ShouldBe(0); + myStateEntities[0].MultipleCheckCount.ShouldBe(1); + myStateEntities[0].MultipleGlobalCheckCount.ShouldBe(0); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities[1])).ShouldBeFalse(); + + myStateEntities[1].CheckCount.ShouldBe(1); + myStateEntities[1].GlobalCheckCount.ShouldBe(0); + myStateEntities[1].MultipleCheckCount.ShouldBe(0); + myStateEntities[1].MultipleGlobalCheckCount.ShouldBe(0); + } + + [Fact] + public async Task Multiple_And_Simple_State_Check_Should_Be_Prevent_Multiple_Checks() + { + var myStateEntities = new SimpleStateCheckerTestBase.MyStateEntity[] + { + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture) + }, + + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture), + } + }; + + myStateEntities[0].AddSimpleStateChecker(new MySimpleBatchStateChecker()); + myStateEntities[1].AddSimpleStateChecker(new MySimpleStateChecker()); + + var result = await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities); + result.Count.ShouldBe(2); + + result[myStateEntities[0]].ShouldBeTrue(); + result[myStateEntities[1]].ShouldBeFalse(); + + myStateEntities[0].CheckCount.ShouldBe(0); + myStateEntities[0].GlobalCheckCount.ShouldBe(0); + myStateEntities[0].MultipleCheckCount.ShouldBe(1); + myStateEntities[0].MultipleGlobalCheckCount.ShouldBe(0); + + myStateEntities[1].CheckCount.ShouldBe(1); + myStateEntities[1].GlobalCheckCount.ShouldBe(0); + myStateEntities[1].MultipleCheckCount.ShouldBe(0); + myStateEntities[1].MultipleGlobalCheckCount.ShouldBe(0); + } + } +} diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_GlobalCheckCount_Test.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_GlobalCheckCount_Test.cs new file mode 100644 index 0000000000..c727238139 --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_GlobalCheckCount_Test.cs @@ -0,0 +1,95 @@ +using System; +using System.Globalization; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Shouldly; +using Xunit; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateChecker_GlobalCheckCount_Test : SimpleStateCheckerTestBase + { + protected override void AfterAddApplication(IServiceCollection services) + { + services.Configure>(options => + { + options.GlobalStateCheckers.Add(); + options.GlobalStateCheckers.Add(); + }); + + base.AfterAddApplication(services); + } + + [Fact] + public async Task Simple_State_Check_Should_Be_Prevent_Multiple_Checks() + { + var myStateEntities = new SimpleStateCheckerTestBase.MyStateEntity[] + { + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture), + LastModificationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture) + }, + + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture) + } + }; + + myStateEntities[0].AddSimpleStateChecker(new MySimpleBatchStateChecker()); + myStateEntities[1].AddSimpleStateChecker(new MySimpleStateChecker()); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities[0])).ShouldBeTrue(); + + myStateEntities[0].CheckCount.ShouldBe(0); + myStateEntities[0].GlobalCheckCount.ShouldBe(1); + myStateEntities[0].MultipleCheckCount.ShouldBe(1); + myStateEntities[0].MultipleGlobalCheckCount.ShouldBe(1); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities[1])).ShouldBeFalse(); + + myStateEntities[1].CheckCount.ShouldBe(1); + myStateEntities[1].GlobalCheckCount.ShouldBe(0); + myStateEntities[1].MultipleCheckCount.ShouldBe(0); + myStateEntities[1].MultipleGlobalCheckCount.ShouldBe(0); + } + + [Fact] + public async Task Multiple_And_Simple_State_Check_Should_Be_Prevent_Multiple_Checks() + { + var myStateEntities = new SimpleStateCheckerTestBase.MyStateEntity[] + { + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture), + LastModificationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture) + }, + + new SimpleStateCheckerTestBase.MyStateEntity() + { + CreationTime = DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture) + } + }; + + myStateEntities[0].AddSimpleStateChecker(new MySimpleBatchStateChecker()); + myStateEntities[1].AddSimpleStateChecker(new MySimpleStateChecker()); + + var result = await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities); + result.Count.ShouldBe(2); + + result[myStateEntities[0]].ShouldBeTrue(); + result[myStateEntities[1]].ShouldBeFalse(); + + myStateEntities[0].CheckCount.ShouldBe(0); + myStateEntities[0].GlobalCheckCount.ShouldBe(1); + myStateEntities[0].MultipleCheckCount.ShouldBe(1); + myStateEntities[0].MultipleGlobalCheckCount.ShouldBe(1); + + myStateEntities[1].CheckCount.ShouldBe(0); + myStateEntities[1].GlobalCheckCount.ShouldBe(0); + myStateEntities[1].MultipleCheckCount.ShouldBe(0); + myStateEntities[1].MultipleGlobalCheckCount.ShouldBe(1); + } + } +} diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_Tests.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_Tests.cs new file mode 100644 index 0000000000..06b7cf2eb7 --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_Tests.cs @@ -0,0 +1,105 @@ +using System; +using System.Globalization; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Shouldly; +using Xunit; + +namespace Volo.Abp.SimpleStateChecking +{ + public class SimpleStateChecker_Tests : SimpleStateCheckerTestBase + { + protected override void AfterAddApplication(IServiceCollection services) + { + services.Configure>(options => + { + options.GlobalStateCheckers.Add(); + options.GlobalStateCheckers.Add(); + }); + + base.AfterAddApplication(services); + } + + [Fact] + public async Task State_Check_Should_Be_Works() + { + var myStateEntity = new MyStateEntity() + { + CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture), + LastModificationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture) + }; + myStateEntity.AddSimpleStateChecker(new MySimpleStateChecker()); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeTrue(); + + myStateEntity.CreationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeFalse(); + } + + [Fact] + public async Task Global_State_Check_Should_Be_Works() + { + var myStateEntity = new MyStateEntity() + { + CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture) + }; + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeFalse(); + + myStateEntity.LastModificationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeTrue(); + } + + [Fact] + public async Task Multiple_State_Check_Should_Be_Works() + { + var checker = new MySimpleBatchStateChecker(); + + var myStateEntities = new MyStateEntity[] + { + new MyStateEntity() + { + CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture), + LastModificationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture) + }, + + new MyStateEntity() + { + CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture), + LastModificationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture) + } + }; + + foreach (var myStateEntity in myStateEntities) + { + myStateEntity.AddSimpleStateChecker(checker); + } + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities)).ShouldAllBe(x => x.Value); + + foreach (var myStateEntity in myStateEntities) + { + myStateEntity.CreationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture); + } + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities)).ShouldAllBe(x => !x.Value); + } + + [Fact] + public async Task Multiple_Global_State_Check_Should_Be_Works() + { + var myStateEntity = new MyStateEntity() + { + CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture) + }; + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeFalse(); + + myStateEntity.LastModificationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture); + + (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeTrue(); + } + } +} diff --git a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs index c72082945b..d641969f9a 100644 --- a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs +++ b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NSubstitute; using Shouldly; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Security.Claims; using Volo.Abp.Testing; using Xunit; @@ -73,8 +74,8 @@ namespace Volo.Abp.UI.Navigation var administration = context.Menu.GetAdministration(); - administration.AddItem(new ApplicationMenuItem("Administration.UserManagement", "User Management", url: "/admin/users", requiredPermissionName: "Administration.UserManagement")); - administration.AddItem(new ApplicationMenuItem("Administration.RoleManagement", "Role Management", url: "/admin/roles", requiredPermissionName: "Administration.RoleManagement")); + administration.AddItem(new ApplicationMenuItem("Administration.UserManagement", "User Management", url: "/admin/users").RequirePermissions("Administration.UserManagement")); + administration.AddItem(new ApplicationMenuItem("Administration.RoleManagement", "Role Management", url: "/admin/roles").RequirePermissions("Administration.RoleManagement")); return Task.CompletedTask; } @@ -94,16 +95,16 @@ namespace Volo.Abp.UI.Navigation return Task.CompletedTask; } - context.Menu.Items.Insert(0, new ApplicationMenuItem("Dashboard", "Dashboard", url: "/dashboard", requiredPermissionName: "Dashboard")); + context.Menu.Items.Insert(0, new ApplicationMenuItem("Dashboard", "Dashboard", url: "/dashboard").RequirePermissions("Dashboard")); var administration = context.Menu.GetAdministration(); - administration.AddItem(new ApplicationMenuItem("Administration.DashboardSettings", "Dashboard Settings", url: "/admin/settings/dashboard", requiredPermissionName: "Administration.DashboardSettings")); + administration.AddItem(new ApplicationMenuItem("Administration.DashboardSettings", "Dashboard Settings", url: "/admin/settings/dashboard").RequirePermissions("Administration.DashboardSettings")); administration.AddItem( new ApplicationMenuItem("Administration.SubMenu1", "Sub menu 1", url: "/submenu1") - .AddItem(new ApplicationMenuItem("Administration.SubMenu1.1", "Sub menu 1.1", url: "/submenu1/submenu1_1", requiredPermissionName: "Administration.SubMenu1.1")) - .AddItem(new ApplicationMenuItem("Administration.SubMenu1.2", "Sub menu 1.2", url: "/submenu1/submenu1_2", requiredPermissionName: "Administration.SubMenu1.2")) + .AddItem(new ApplicationMenuItem("Administration.SubMenu1.1", "Sub menu 1.1", url: "/submenu1/submenu1_1").RequirePermissions("Administration.SubMenu1.1")) + .AddItem(new ApplicationMenuItem("Administration.SubMenu1.2", "Sub menu 1.2", url: "/submenu1/submenu1_2").RequirePermissions("Administration.SubMenu1.2")) ); return Task.CompletedTask; diff --git a/modules/account/Volo.Abp.Account.abpmdl.json b/modules/account/Volo.Abp.Account.abpmdl.json index c6135f99c5..28927ae184 100644 --- a/modules/account/Volo.Abp.Account.abpmdl.json +++ b/modules/account/Volo.Abp.Account.abpmdl.json @@ -1,65 +1,42 @@ { "folders": { - "src": {}, - "test": {} - }, - "imports": { - "Volo.Abp.Identity": { - "path": "../identity/Volo.Abp.Identity.abpmdl.json" - }, - "Volo.Abp.PermissionManagement": { - "path": "../permission-management/Volo.Abp.PermissionManagement.abpmdl.json" + "items": { + "src": {}, + "test": {} } }, "packages": { - "Volo.Abp.Account.Application.Contracts": { - "path": "src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.csproj", - "folder": "src", - "includes": { - "lib.application.contracts": {} - } + "Volo.Abp.Account.Web": { + "path": "src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.abppkg.json", + "folder": "src" + }, + "Volo.Abp.Account.Web.IdentityServer": { + "path": "src/Volo.Abp.Account.Web.IdentityServer/Volo.Abp.Account.Web.IdentityServer.abppkg.json", + "folder": "src" }, "Volo.Abp.Account.Application": { - "path": "src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.csproj", - "folder": "src", - "includes": { - "lib.application": {} - } + "path": "src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.abppkg.json", + "folder": "src" + }, + "Volo.Abp.Account.Application.Contracts": { + "path": "src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.json", + "folder": "src" }, "Volo.Abp.Account.HttpApi": { - "path": "src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.csproj", - "folder": "src", - "includes": { - "lib.http-api": {} - } + "path": "src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.abppkg.json", + "folder": "src" }, "Volo.Abp.Account.HttpApi.Client": { - "path": "src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.csproj", - "folder": "src", - "includes": { - "lib.http-api-client": {} - } - }, - "Volo.Abp.Account.Web": { - "path": "src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj", - "folder": "src", - "includes": { - "lib.ui.mvc": {} - } - }, - "Volo.Abp.Account.Web.IdentityServer": { - "path": "src/Volo.Abp.Account.IdentityServer/Volo.Abp.Account.IdentityServer.csproj", - "folder": "src", - "includes": { - "lib.ui.mvc": {} - } + "path": "src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.abppkg.json", + "folder": "src" }, "Volo.Abp.Account.Application.Tests": { - "path": "test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.Account.Blazor": { + "path": "src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.abppkg.json", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.json new file mode 100644 index 0000000000..49032794e2 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application-contracts" +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.abppkg.json b/modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.abppkg.json new file mode 100644 index 0000000000..412567ac33 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application" +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.abppkg.json b/modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.abppkg.json new file mode 100644 index 0000000000..19c29b7b8b --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor" +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.abppkg.json b/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.abppkg.json new file mode 100644 index 0000000000..7deef5e383 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api-client" +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.abppkg.json b/modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.abppkg.json new file mode 100644 index 0000000000..515bfe64c4 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api" +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Volo.Abp.Account.Web.IdentityServer.abppkg.json b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Volo.Abp.Account.Web.IdentityServer.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Volo.Abp.Account.Web.IdentityServer.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.abppkg.json b/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.abppkg.json new file mode 100644 index 0000000000..930c4018b3 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mvc" +} \ No newline at end of file diff --git a/modules/account/test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.abppkg.json b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/audit-logging/Volo.Abp.AuditLogging.abpmdl.json b/modules/audit-logging/Volo.Abp.AuditLogging.abpmdl.json index a21497b1cb..5b2cc3f54b 100644 --- a/modules/audit-logging/Volo.Abp.AuditLogging.abpmdl.json +++ b/modules/audit-logging/Volo.Abp.AuditLogging.abpmdl.json @@ -1,64 +1,42 @@ { "folders": { - "src": {}, - "test": {} + "items": { + "src": {}, + "test": {} + } }, "packages": { "Volo.Abp.AuditLogging.Domain.Shared": { - "path": "src/Volo.Abp.AuditLogging.Domain.Shared/Volo.Abp.AuditLogging.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.AuditLogging.Domain.Shared/Volo.Abp.AuditLogging.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.AuditLogging.Domain": { - "path": "src/Volo.Abp.AuditLogging.Domain/Volo.Abp.AuditLogging.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.AuditLogging.Domain/Volo.Abp.AuditLogging.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.AuditLogging.EntityFrameworkCore": { - "path": "src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo.Abp.AuditLogging.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo.Abp.AuditLogging.EntityFrameworkCore.abppkg.json", + "folder": "src" }, "Volo.Abp.AuditLogging.MongoDB": { - "path": "src/Volo.Abp.AuditLogging.MongoDB/Volo.Abp.AuditLogging.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } - }, - "Volo.Abp.AuditLogging.TestBase": { - "path": "test/Volo.Abp.AuditLogging.TestBase/Volo.Abp.AuditLogging.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "src/Volo.Abp.AuditLogging.MongoDB/Volo.Abp.AuditLogging.MongoDB.abppkg.json", + "folder": "src" }, "Volo.Abp.AuditLogging.Tests": { - "path": "test/Volo.Abp.AuditLogging.Tests/Volo.Abp.AuditLogging.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.AuditLogging.Tests/Volo.Abp.AuditLogging.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.AuditLogging.TestBase": { + "path": "test/Volo.Abp.AuditLogging.TestBase/Volo.Abp.AuditLogging.TestBase.abppkg.json", + "folder": "test" }, "Volo.Abp.AuditLogging.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.AuditLogging.MongoDB.Tests": { - "path": "test/Volo.Abp.AuditLogging.MongoDB.Tests/Volo.Abp.AuditLogging.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.AuditLogging.MongoDB.Tests/Volo.Abp.AuditLogging.MongoDB.Tests.abppkg.json", + "folder": "test" } } } \ No newline at end of file diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo.Abp.AuditLogging.Domain.Shared.abppkg.json b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo.Abp.AuditLogging.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo.Abp.AuditLogging.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo.Abp.AuditLogging.Domain.abppkg.json b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo.Abp.AuditLogging.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo.Abp.AuditLogging.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo.Abp.AuditLogging.EntityFrameworkCore.abppkg.json b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo.Abp.AuditLogging.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo.Abp.AuditLogging.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo.Abp.AuditLogging.MongoDB.abppkg.json b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo.Abp.AuditLogging.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo.Abp.AuditLogging.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests.abppkg.json b/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.MongoDB.Tests/Volo.Abp.AuditLogging.MongoDB.Tests.abppkg.json b/modules/audit-logging/test/Volo.Abp.AuditLogging.MongoDB.Tests/Volo.Abp.AuditLogging.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.MongoDB.Tests/Volo.Abp.AuditLogging.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo.Abp.AuditLogging.TestBase.abppkg.json b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo.Abp.AuditLogging.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo.Abp.AuditLogging.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo.Abp.AuditLogging.Tests.abppkg.json b/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo.Abp.AuditLogging.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo.Abp.AuditLogging.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/background-jobs/Volo.Abp.BackgroundJobs.abpmdl.json b/modules/background-jobs/Volo.Abp.BackgroundJobs.abpmdl.json index da2cab8b84..e3bea65da3 100644 --- a/modules/background-jobs/Volo.Abp.BackgroundJobs.abpmdl.json +++ b/modules/background-jobs/Volo.Abp.BackgroundJobs.abpmdl.json @@ -1,64 +1,63 @@ { "folders": { - "src": {}, - "test": {} + "items": { + "src": {}, + "test": {}, + "app": {} + } }, "packages": { "Volo.Abp.BackgroundJobs.Domain.Shared": { - "path": "src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo.Abp.BackgroundJobs.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo.Abp.BackgroundJobs.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.BackgroundJobs.Domain": { - "path": "src/Volo.Abp.BackgroundJobs.Domain/Volo.Abp.BackgroundJobs.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.BackgroundJobs.Domain/Volo.Abp.BackgroundJobs.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.BackgroundJobs.EntityFrameworkCore": { - "path": "src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo.Abp.BackgroundJobs.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo.Abp.BackgroundJobs.EntityFrameworkCore.abppkg.json", + "folder": "src" }, "Volo.Abp.BackgroundJobs.MongoDB": { - "path": "src/Volo.Abp.BackgroundJobs.MongoDB/Volo.Abp.BackgroundJobs.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } + "path": "src/Volo.Abp.BackgroundJobs.MongoDB/Volo.Abp.BackgroundJobs.MongoDB.abppkg.json", + "folder": "src" }, "Volo.Abp.BackgroundJobs.TestBase": { - "path": "test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp.BackgroundJobs.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp.BackgroundJobs.TestBase.abppkg.json", + "folder": "test" }, "Volo.Abp.BackgroundJobs.Domain.Tests": { - "path": "test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo.Abp.BackgroundJobs.Domain.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo.Abp.BackgroundJobs.Domain.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.BackgroundJobs.MongoDB.Tests": { - "path": "test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo.Abp.BackgroundJobs.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo.Abp.BackgroundJobs.MongoDB.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.BackgroundJobs.DemoApp": { + "path": "app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.abppkg.json", + "folder": "app" + }, + "Volo.Abp.BackgroundJobs.DemoApp.Shared": { + "path": "app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.abppkg.json", + "folder": "app" + }, + "Volo.Abp.BackgroundJobs.DemoApp.HangFire": { + "path": "app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.abppkg.json", + "folder": "app" + }, + "Volo.Abp.BackgroundJobs.DemoApp.RabbitMq": { + "path": "app/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq.abppkg.json", + "folder": "app" + }, + "Volo.Abp.BackgroundJobs.DemoApp.Quartz": { + "path": "app/Volo.Abp.BackgroundJobs.DemoApp.Quartz/Volo.Abp.BackgroundJobs.DemoApp.Quartz.abppkg.json", + "folder": "app" } } } \ No newline at end of file diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.abppkg.json b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Quartz/Volo.Abp.BackgroundJobs.DemoApp.Quartz.abppkg.json b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Quartz/Volo.Abp.BackgroundJobs.DemoApp.Quartz.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Quartz/Volo.Abp.BackgroundJobs.DemoApp.Quartz.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq.abppkg.json b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq/Volo.Abp.BackgroundJobs.DemoApp.RabbitMq.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.abppkg.json b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.abppkg.json b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo.Abp.BackgroundJobs.Domain.Shared.abppkg.json b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo.Abp.BackgroundJobs.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo.Abp.BackgroundJobs.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo.Abp.BackgroundJobs.Domain.abppkg.json b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo.Abp.BackgroundJobs.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo.Abp.BackgroundJobs.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo.Abp.BackgroundJobs.EntityFrameworkCore.abppkg.json b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo.Abp.BackgroundJobs.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo.Abp.BackgroundJobs.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo.Abp.BackgroundJobs.MongoDB.abppkg.json b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo.Abp.BackgroundJobs.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo.Abp.BackgroundJobs.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo.Abp.BackgroundJobs.Domain.Tests.abppkg.json b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo.Abp.BackgroundJobs.Domain.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo.Abp.BackgroundJobs.Domain.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests.abppkg.json b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo.Abp.BackgroundJobs.MongoDB.Tests.abppkg.json b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo.Abp.BackgroundJobs.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo.Abp.BackgroundJobs.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp.BackgroundJobs.TestBase.abppkg.json b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp.BackgroundJobs.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp.BackgroundJobs.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpmdl.json b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpmdl.json index 2d5e84ad96..f5f118cbdc 100644 --- a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpmdl.json +++ b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpmdl.json @@ -1,64 +1,55 @@ { "folders": { - "src": {}, - "test": {} + "items": { + "src": {}, + "test": {}, + "host": { + "items": { + "BlobStoring.Database.Host.ConsoleApp": { + "items": { + "src": {} + } + } + } + } + } }, "packages": { "Volo.Abp.BlobStoring.Database.Domain.Shared": { - "path": "src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.BlobStoring.Database.Domain": { - "path": "src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.BlobStoring.Database.EntityFrameworkCore": { - "path": "src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.abppkg.json", + "folder": "src" }, "Volo.Abp.BlobStoring.Database.MongoDB": { - "path": "src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } + "path": "src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.abppkg.json", + "folder": "src" }, "Volo.Abp.BlobStoring.Database.TestBase": { - "path": "test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.BlobStoring.Database.Domain.Tests": { - "path": "test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.abppkg.json", + "folder": "test" }, "Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.BlobStoring.Database.MongoDB.Tests": { - "path": "test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.BlobStoring.Database.Domain.Tests": { + "path": "test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.abppkg.json", + "folder": "test" + }, + "BlobStoring.Database.Host.ConsoleApp.ConsoleApp": { + "path": "host/BlobStoring.Database.Host.ConsoleApp/src/BlobStoring.Database.Host.ConsoleApp.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.ConsoleApp.abppkg.json", + "folder": "host/BlobStoring.Database.Host.ConsoleApp/src" } } } \ No newline at end of file diff --git a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpsln.json b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpsln.json index 3261567c56..e90f5d10ff 100644 --- a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpsln.json +++ b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.abpsln.json @@ -2,6 +2,9 @@ "modules": { "Volo.Abp.BlobStoring.Database": { "path": "Volo.Abp.BlobStoring.Database.abpmdl.json" + }, + "BlobStoring.Database.Host.ConsoleApp": { + "path": "host/BlobStoring.Database.Host.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.abpmdl.json" } } } \ No newline at end of file diff --git a/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.abpmdl.json b/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.abpmdl.json new file mode 100644 index 0000000000..e8b2a715c8 --- /dev/null +++ b/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.abpmdl.json @@ -0,0 +1,13 @@ +{ + "folders": { + "items": { + "src": {} + } + }, + "packages": { + "BlobStoring.Database.Host.ConsoleApp.ConsoleApp": { + "path": "src/BlobStoring.Database.Host.ConsoleApp.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.ConsoleApp.abppkg.json", + "folder": "src" + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/src/BlobStoring.Database.Host.ConsoleApp.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.ConsoleApp.abppkg.json b/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/src/BlobStoring.Database.Host.ConsoleApp.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.ConsoleApp.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/blob-storing-database/host/BlobStoring.Database.Host.ConsoleApp/src/BlobStoring.Database.Host.ConsoleApp.ConsoleApp/BlobStoring.Database.Host.ConsoleApp.ConsoleApp.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.abppkg.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.abppkg.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.abppkg.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.abppkg.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.abppkg.json b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.abppkg.json b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.abppkg.json b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.abppkg.json b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs index 43e4bfca5b..93fe6c60d7 100644 --- a/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; using Volo.Blogging.Localization; namespace Volo.Blogging.Admin @@ -18,9 +19,9 @@ namespace Volo.Blogging.Admin { var l = context.GetLocalizer(); - var managementRootMenuItem = new ApplicationMenuItem("BlogManagement", l["Menu:BlogManagement"], requiredPermissionName: BloggingPermissions.Blogs.Management); + var managementRootMenuItem = new ApplicationMenuItem("BlogManagement", l["Menu:BlogManagement"]).RequirePermissions(BloggingPermissions.Blogs.Management); - managementRootMenuItem.AddItem(new ApplicationMenuItem("BlogManagement.Blogs", l["Menu:Blogs"], "~/Blogging/Admin/Blogs", requiredPermissionName: BloggingPermissions.Blogs.Management)); + managementRootMenuItem.AddItem(new ApplicationMenuItem("BlogManagement.Blogs", l["Menu:Blogs"], "~/Blogging/Admin/Blogs").RequirePermissions(BloggingPermissions.Blogs.Management)); context.Menu.GetAdministration().AddItem(managementRootMenuItem); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml index 1aa239efd7..a4fcbc0414 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml @@ -7,7 +7,7 @@ @inject IHtmlLocalizer L @model EditModel @{ - ViewBag.PageTitle = "Blog"; + ViewBag.PageTitle = "Edit Blog Post"; } @section styles { diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml index db9644a9ed..c325513079 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml @@ -11,7 +11,7 @@ @inject IHtmlLocalizer L @inject BloggingPageHelper BloggingPageHelper @{ - ViewBag.Title = "Blog"; + ViewBag.Title = "Read All Blog Posts"; } @section scripts { diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml index d57fd1b772..810a0e3203 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml @@ -7,7 +7,7 @@ @inject IHtmlLocalizer L @model NewModel @{ - ViewBag.PageTitle = "Blog"; + ViewBag.PageTitle = "New Blog Post"; } @section styles { diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs index 1f1421546e..66a3364eae 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs @@ -4,6 +4,7 @@ using Localization.Resources.AbpUi; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; +using Volo.Abp.Authorization.Permissions; using Volo.CmsKit.Localization; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; @@ -31,30 +32,26 @@ namespace Volo.CmsKit private void AddLogoutItemToMenu(MenuConfigurationContext context) { - var currentUser = context.ServiceProvider.GetRequiredService(); var l = context.GetLocalizer(); - if (currentUser.IsAuthenticated) - { - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Manage", - l["ManageYourProfile"], - $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", - icon: "fa fa-cog", - order: int.MaxValue - 1001, - null, - "_blank") - ); - - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Logout", - l["Logout"], - "~/Account/Logout", - "fas fa-power-off", - order: int.MaxValue - 1000 - )); - } + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Manage", + l["ManageYourProfile"], + $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", + icon: "fa fa-cog", + order: int.MaxValue - 1001, + null, + "_blank" + ).RequireAuthenticated()); + + + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Logout", + l["Logout"], + "~/Account/Logout", + "fas fa-power-off", + order: int.MaxValue - 1000 + ).RequireAuthenticated()); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs index d5d69405b6..7a11c7d73a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.GlobalFeatures; using Volo.Abp.UI.Navigation; using Volo.CmsKit.GlobalFeatures; @@ -29,67 +30,46 @@ namespace Volo.CmsKit.Admin.Web.Menus var l = context.GetLocalizer(); var cmsMenus = new List(); - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - if (await context.IsGrantedAsync(CmsKitAdminPermissions.Pages.Default)) - { - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Pages.PagesMenu, - l["Pages"].Value, - "/Cms/Pages", - "fa fa-file-alt")); - } - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - if (await context.IsGrantedAsync(CmsKitAdminPermissions.Blogs.Default)) - { - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Blogs.BlogsMenu, - l["Blogs"], - "/Cms/Blogs", - "fa fa-blog" - )); - } - if (await context.IsGrantedAsync(CmsKitAdminPermissions.BlogPosts.Default)) - { - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.BlogPosts.BlogPostsMenu, - l["BlogPosts"], - "/Cms/BlogPosts", - "fa fa-file-signature" - )); - } - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - if (await context.IsGrantedAsync(CmsKitAdminPermissions.Tags.Default)) - { - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Tags.TagsMenu, - l["Tags"].Value, - "/Cms/Tags", - "fa fa-tags")); - } - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - if (await context.IsGrantedAsync(CmsKitAdminPermissions.Comments.Default)) - { - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Comments.CommentsMenu, - l["Comments"].Value, - "/Cms/Comments", - "fa fa-comments" - ) - ); - } - } + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Pages.PagesMenu, + l["Pages"].Value, + "/Cms/Pages", + "fa fa-file-alt") + .RequireGlobalFeatures(typeof(PagesFeature)) + .RequirePermissions(CmsKitAdminPermissions.Pages.Default)); + + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Blogs.BlogsMenu, + l["Blogs"], + "/Cms/Blogs", + "fa fa-blog") + .RequireGlobalFeatures(typeof(BlogsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Blogs.Default)); + + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.BlogPosts.BlogPostsMenu, + l["BlogPosts"], + "/Cms/BlogPosts", + "fa fa-file-signature") + .RequireGlobalFeatures(typeof(BlogsFeature)) + .RequirePermissions(CmsKitAdminPermissions.BlogPosts.Default)); + + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Tags.TagsMenu, + l["Tags"].Value, + "/Cms/Tags", + "fa fa-tags") + .RequireGlobalFeatures(typeof(TagsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Tags.Default)); + + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Comments.CommentsMenu, + l["Comments"].Value, + "/Cms/Comments", + "fa fa-comments") + .RequireGlobalFeatures(typeof(CommentsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Comments.Default)); if (cmsMenus.Any()) { @@ -112,4 +92,4 @@ namespace Volo.CmsKit.Admin.Web.Menus } } } -} \ No newline at end of file +} diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs index f72644065d..ed36c4dc0e 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs @@ -27,7 +27,7 @@ namespace Volo.Docs.Admin.Documents private readonly IDistributedCache _documentUpdateCache; private readonly IDistributedCache> _versionCache; private readonly IDistributedCache _languageCache; - private readonly IDocumentFullSearch _documentFullSearch; + private readonly IDocumentFullSearch _elasticSearchService; public DocumentAdminAppService(IProjectRepository projectRepository, IDocumentRepository documentRepository, @@ -35,7 +35,7 @@ namespace Volo.Docs.Admin.Documents IDistributedCache documentUpdateCache, IDistributedCache> versionCache, IDistributedCache languageCache, - IDocumentFullSearch documentFullSearch) + IDocumentFullSearch elasticSearchService) { _projectRepository = projectRepository; _documentRepository = documentRepository; @@ -43,7 +43,7 @@ namespace Volo.Docs.Admin.Documents _documentUpdateCache = documentUpdateCache; _versionCache = versionCache; _languageCache = languageCache; - _documentFullSearch = documentFullSearch; + _elasticSearchService = elasticSearchService; LocalizationResource = typeof(DocsResource); } @@ -210,9 +210,11 @@ namespace Volo.Docs.Admin.Documents public async Task ReindexAsync(Guid documentId) { - await _documentFullSearch.DeleteAsync(documentId); + _elasticSearchService.ValidateElasticSearchEnabled(); + + await _elasticSearchService.DeleteAsync(documentId); var document = await _documentRepository.GetAsync(documentId); - await _documentFullSearch.AddOrUpdateAsync(document); + await _elasticSearchService.AddOrUpdateAsync(document); } private async Task UpdateDocumentUpdateInfoCache(Document document) diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs index bc663a0252..24605f1cc8 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; @@ -18,13 +17,13 @@ namespace Volo.Docs.Admin.Projects { private readonly IProjectRepository _projectRepository; private readonly IDocumentRepository _documentRepository; - private readonly IDocumentFullSearch _documentFullSearch; + private readonly IDocumentFullSearch _elasticSearchService; private readonly IGuidGenerator _guidGenerator; public ProjectAdminAppService( IProjectRepository projectRepository, IDocumentRepository documentRepository, - IDocumentFullSearch documentFullSearch, + IDocumentFullSearch elasticSearchService, IGuidGenerator guidGenerator) { ObjectMapperContext = typeof(DocsAdminApplicationModule); @@ -32,7 +31,7 @@ namespace Volo.Docs.Admin.Projects _projectRepository = projectRepository; _documentRepository = documentRepository; - _documentFullSearch = documentFullSearch; + _elasticSearchService = elasticSearchService; _guidGenerator = guidGenerator; } @@ -120,11 +119,21 @@ namespace Volo.Docs.Admin.Projects public async Task ReindexAsync(ReindexInput input) { - var project = await _projectRepository.GetAsync(input.ProjectId); + _elasticSearchService.ValidateElasticSearchEnabled(); - await _documentFullSearch.DeleteAllByProjectIdAsync(project.Id); + await ReindexProjectAsync(input.ProjectId); + } + + private async Task ReindexProjectAsync(Guid projectId) + { + var project = await _projectRepository.FindAsync(projectId); + if (project == null) + { + throw new Exception("Cannot find the project with the Id " + projectId); + } var docs = await _documentRepository.GetListByProjectId(project.Id); + await _elasticSearchService.DeleteAllByProjectIdAsync(project.Id); foreach (var doc in docs) { @@ -138,35 +147,18 @@ namespace Volo.Docs.Admin.Projects continue; } - await _documentFullSearch.AddOrUpdateAsync(doc); + await _elasticSearchService.AddOrUpdateAsync(doc); } } public async Task ReindexAllAsync() { - await _documentFullSearch.DeleteAllAsync(); - - var docs = await _documentRepository.GetListAsync(); + _elasticSearchService.ValidateElasticSearchEnabled(); var projects = await _projectRepository.GetListAsync(); - foreach (var doc in docs) + + foreach (var project in projects) { - var project = projects.FirstOrDefault(x => x.Id == doc.ProjectId); - if (project == null) - { - continue; - } - - if (doc.FileName == project.NavigationDocumentName) - { - continue; - } - - if (doc.FileName == project.ParametersDocumentName) - { - continue; - } - - await _documentFullSearch.AddOrUpdateAsync(doc); + await ReindexProjectAsync(project.Id); } } } diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Navigation/DocsMenuContributor.cs b/modules/docs/src/Volo.Docs.Admin.Web/Navigation/DocsMenuContributor.cs index 644dd037c4..41eba37ced 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Navigation/DocsMenuContributor.cs +++ b/modules/docs/src/Volo.Docs.Admin.Web/Navigation/DocsMenuContributor.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; using Volo.Docs.Localization; namespace Volo.Docs.Admin.Navigation @@ -27,8 +28,8 @@ namespace Volo.Docs.Admin.Navigation administrationMenu.AddItem(rootMenuItem); - rootMenuItem.AddItem(new ApplicationMenuItem(DocsMenuNames.Projects, l["Menu:ProjectManagement"], "~/Docs/Admin/Projects", requiredPermissionName: DocsAdminPermissions.Projects.Default)); - rootMenuItem.AddItem(new ApplicationMenuItem(DocsMenuNames.Documents, l["Menu:DocumentManagement"], "~/Docs/Admin/Documents", requiredPermissionName: DocsAdminPermissions.Documents.Default)); + rootMenuItem.AddItem(new ApplicationMenuItem(DocsMenuNames.Projects, l["Menu:ProjectManagement"], "~/Docs/Admin/Projects").RequirePermissions(DocsAdminPermissions.Projects.Default)); + rootMenuItem.AddItem(new ApplicationMenuItem(DocsMenuNames.Documents, l["Menu:DocumentManagement"], "~/Docs/Admin/Documents").RequirePermissions(DocsAdminPermissions.Documents.Default)); return Task.CompletedTask; } diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/ElasticDocumentFullSearch.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/ElasticDocumentFullSearch.cs index 7160ca405b..7a47cd7b45 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/ElasticDocumentFullSearch.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/ElasticDocumentFullSearch.cs @@ -56,8 +56,6 @@ namespace Volo.Docs.Documents.FullSearch.Elastic public virtual async Task AddOrUpdateAsync(Document document, CancellationToken cancellationToken = default) { - ValidateElasticSearchEnabled(); - var client = _clientProvider.GetClient(); var esDocument = new EsDocument @@ -71,15 +69,13 @@ namespace Volo.Docs.Documents.FullSearch.Elastic Version = NormalizeField(document.Version) }; - await client.IndexAsync(esDocument , x=>x.Index(_options.IndexName), cancellationToken); + await client.IndexAsync(esDocument, x => x.Index(_options.IndexName), cancellationToken); } public virtual async Task DeleteAsync(Guid id, CancellationToken cancellationToken = default) { - ValidateElasticSearchEnabled(); - HandleError(await _clientProvider.GetClient() - .DeleteAsync(DocumentPath.Id( NormalizeField(id)), x => x.Index(_options.IndexName), cancellationToken)); + .DeleteAsync(DocumentPath.Id(NormalizeField(id)), x => x.Index(_options.IndexName), cancellationToken)); } public virtual async Task DeleteAllAsync(CancellationToken cancellationToken = default) @@ -210,7 +206,7 @@ namespace Volo.Docs.Documents.FullSearch.Elastic } } - protected virtual void ValidateElasticSearchEnabled() + public virtual void ValidateElasticSearchEnabled() { if (!_options.Enable) { diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/IDocumentFullSearch.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/IDocumentFullSearch.cs index e05c31bda3..c84df577b7 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/IDocumentFullSearch.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/FullSearch/Elastic/IDocumentFullSearch.cs @@ -20,5 +20,7 @@ namespace Volo.Docs.Documents.FullSearch.Elastic Task> SearchAsync(string context, Guid projectId, string languageCode, string version, int? skipCount = null, int? maxResultCount = null, CancellationToken cancellationToken = default); + + void ValidateElasticSearchEnabled(); } } diff --git a/modules/docs/src/Volo.Docs.Web/Bundling/PrismjsScriptBundleContributorDocsExtension.cs b/modules/docs/src/Volo.Docs.Web/Bundling/PrismjsScriptBundleContributorDocsExtension.cs index 9406c2f6f2..9309234be7 100644 --- a/modules/docs/src/Volo.Docs.Web/Bundling/PrismjsScriptBundleContributorDocsExtension.cs +++ b/modules/docs/src/Volo.Docs.Web/Bundling/PrismjsScriptBundleContributorDocsExtension.cs @@ -5,14 +5,47 @@ namespace Volo.Docs.Bundling { public class PrismjsScriptBundleContributorDocsExtension : BundleContributor { + private static readonly string[] SupportedLanguages = new[] { + "csharp", + "json", + "aspnet", + "bash", + "css", + "css-extras", + "docker", + "javascript", + "less", + "markdown", + "nginx", + "powershell", + "regex", + "sass", + "scss", + "sql", + "typescript" + }; + public override void ConfigureBundle(BundleConfigurationContext context) + { + AddPlugins(context); + AddLanguages(context); + } + + private static void AddLanguages(IBundleConfigurationContext context) + { + const string componentsPath = "/libs/prismjs/components/prism-{0}.js"; + foreach (var language in SupportedLanguages) + { + context.Files.AddIfNotContains(string.Format(componentsPath, language)); + } + } + + private static void AddPlugins(IBundleConfigurationContext context) { context.Files.AddIfNotContains("/libs/prismjs/plugins/toolbar/prism-toolbar.js"); context.Files.AddIfNotContains("/libs/prismjs/plugins/show-language/prism-show-language.js"); context.Files.AddIfNotContains("/libs/prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard.js"); context.Files.AddIfNotContains("/libs/prismjs/plugins/line-highlight/prism-line-highlight.js"); - context.Files.AddIfNotContains("/libs/prismjs/components/prism-csharp.js"); - context.Files.AddIfNotContains("/libs/prismjs/components/prism-json.js"); } } } diff --git a/modules/identity/Volo.Abp.Identity.abpmdl.json b/modules/identity/Volo.Abp.Identity.abpmdl.json index 91c285965d..f58988ab30 100644 --- a/modules/identity/Volo.Abp.Identity.abpmdl.json +++ b/modules/identity/Volo.Abp.Identity.abpmdl.json @@ -1,150 +1,90 @@ { "folders": { - "src": {}, - "test": {} - }, - "imports": { - "Volo.Abp.Users": { - "path": "../users/Volo.Abp.Users.abpmdl.json" - }, - "Volo.Abp.PermissionManagement": { - "path": "../permission-management/Volo.Abp.PermissionManagement.abpmdl.json" + "items": { + "src": {}, + "test": {} } }, "packages": { "Volo.Abp.Identity.Domain.Shared": { - "path": "src/Volo.Abp.Identity.Domain.Shared/Volo.Abp.Identity.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.Identity.Domain.Shared/Volo.Abp.Identity.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.Domain": { - "path": "src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.Application.Contracts": { - "path": "src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.csproj", - "folder": "src", - "includes": { - "lib.application.contracts": {} - } + "path": "src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.Application": { - "path": "src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.csproj", - "folder": "src", - "includes": { - "lib.application": {} - } + "path": "src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.EntityFrameworkCore": { - "path": "src/Volo.Abp.Identity.EntityFrameworkCore/Volo.Abp.Identity.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } - }, - "Volo.Abp.Identity.MongoDB": { - "path": "src/Volo.Abp.Identity.MongoDB/Volo.Abp.Identity.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } - }, - "Volo.Abp.Identity.AspNetCore": { - "path": "src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.csproj", + "path": "src/Volo.Abp.Identity.EntityFrameworkCore/Volo.Abp.Identity.EntityFrameworkCore.abppkg.json", "folder": "src" }, "Volo.Abp.Identity.HttpApi": { - "path": "src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.csproj", - "folder": "src", - "includes": { - "lib.http-api": {} - } + "path": "src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.HttpApi.Client": { - "path": "src/Volo.Abp.Identity.HttpApi.Client/Volo.Abp.Identity.HttpApi.Client.csproj", - "folder": "src", - "includes": { - "lib.http-api-client": {} - } + "path": "src/Volo.Abp.Identity.HttpApi.Client/Volo.Abp.Identity.HttpApi.Client.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.Web": { - "path": "src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj", - "folder": "src", - "includes": { - "lib.ui.mvc": {} - } + "path": "src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.abppkg.json", + "folder": "src" }, - "Volo.Abp.Identity.Blazor": { - "path": "src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor": {} - } + "Volo.Abp.Identity.Application.Tests": { + "path": "test/Volo.Abp.Identity.Application.Tests/Volo.Abp.Identity.Application.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.Identity.Blazor.Server": { - "path": "src/Volo.Abp.Identity.Blazor.Server/Volo.Abp.Identity.Blazor.Server.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-server": {} - } + "Volo.Abp.Identity.MongoDB": { + "path": "src/Volo.Abp.Identity.MongoDB/Volo.Abp.Identity.MongoDB.abppkg.json", + "folder": "src" }, - "Volo.Abp.Identity.Blazor.WebAssembly": { - "path": "src/Volo.Abp.Identity.Blazor.WebAssembly/Volo.Abp.Identity.Blazor.WebAssembly.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-wasm": {} - } + "Volo.Abp.Identity.MongoDB.Tests": { + "path": "test/Volo.Abp.Identity.MongoDB.Tests/Volo.Abp.Identity.MongoDB.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.PermissionManagement.Domain.Identity": { - "path": "src/Volo.Abp.PermissionManagement.Domain.Identity/Volo.Abp.PermissionManagement.Domain.Identity.csproj", - "folder": "src" + "Volo.Abp.Identity.EntityFrameworkCore.Tests": { + "path": "test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo.Abp.Identity.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.Identity.TestBase": { - "path": "test/Volo.Abp.Identity.TestBase/Volo.Abp.Identity.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.Identity.TestBase/Volo.Abp.Identity.TestBase.abppkg.json", + "folder": "test" }, "Volo.Abp.Identity.Domain.Tests": { - "path": "test/Volo.Abp.Identity.Domain.Tests/Volo.Abp.Identity.Domain.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.Identity.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo.Abp.Identity.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.Identity.Domain.Tests/Volo.Abp.Identity.Domain.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.Identity.MongoDB.Tests": { - "path": "test/Volo.Abp.Identity.MongoDB.Tests/Volo.Abp.Identity.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.Identity.AspNetCore": { + "path": "src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.abppkg.json", + "folder": "src" }, - "Volo.Abp.Identity.Application.Tests": { - "path": "test/Volo.Abp.Identity.Application.Tests/Volo.Abp.Identity.Application.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.PermissionManagement.Domain.Identity": { + "path": "src/Volo.Abp.PermissionManagement.Domain.Identity/Volo.Abp.PermissionManagement.Domain.Identity.abppkg.json", + "folder": "src" }, "Volo.Abp.Identity.AspNetCore.Tests": { - "path": "test/Volo.Abp.Identity.AspNetCore.Tests/Volo.Abp.Identity.AspNetCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.Identity.AspNetCore.Tests/Volo.Abp.Identity.AspNetCore.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.Identity.Blazor": { + "path": "src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.abppkg.json", + "folder": "src" + }, + "Volo.Abp.Identity.Blazor.Server": { + "path": "src/Volo.Abp.Identity.Blazor.Server/Volo.Abp.Identity.Blazor.Server.abppkg.json", + "folder": "src" + }, + "Volo.Abp.Identity.Blazor.WebAssembly": { + "path": "src/Volo.Abp.Identity.Blazor.WebAssembly/Volo.Abp.Identity.Blazor.WebAssembly.abppkg.json", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.abppkg.json new file mode 100644 index 0000000000..49032794e2 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application-contracts" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.abppkg.json new file mode 100644 index 0000000000..412567ac33 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.abppkg.json b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor.Server/Volo.Abp.Identity.Blazor.Server.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Blazor.Server/Volo.Abp.Identity.Blazor.Server.abppkg.json new file mode 100644 index 0000000000..ef40d81585 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Blazor.Server/Volo.Abp.Identity.Blazor.Server.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-server" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor.WebAssembly/Volo.Abp.Identity.Blazor.WebAssembly.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Blazor.WebAssembly/Volo.Abp.Identity.Blazor.WebAssembly.abppkg.json new file mode 100644 index 0000000000..471ef5e067 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Blazor.WebAssembly/Volo.Abp.Identity.Blazor.WebAssembly.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-wasm" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityWebMainMenuContributor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityWebMainMenuContributor.cs index 9b75491d0b..fafa8eac9b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityWebMainMenuContributor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityWebMainMenuContributor.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Volo.Abp.Identity.Localization; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; namespace Volo.Abp.Identity.Blazor { @@ -24,15 +25,12 @@ namespace Volo.Abp.Identity.Blazor identityMenuItem.AddItem(new ApplicationMenuItem( IdentityMenuNames.Roles, l["Roles"], - url: "~/identity/roles", - requiredPermissionName: IdentityPermissions.Roles.Default)); - + url: "~/identity/roles").RequirePermissions(IdentityPermissions.Roles.Default)); identityMenuItem.AddItem(new ApplicationMenuItem( IdentityMenuNames.Users, l["Users"], - url: "~/identity/users", - requiredPermissionName: IdentityPermissions.Users.Default)); + url: "~/identity/users").RequirePermissions(IdentityPermissions.Users.Default)); return Task.CompletedTask; } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.abppkg.json new file mode 100644 index 0000000000..19c29b7b8b --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo.Abp.Identity.Domain.Shared.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo.Abp.Identity.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo.Abp.Identity.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json index dfc5193e62..20cec1eded 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json @@ -16,8 +16,8 @@ "PersonalInfo": "Mi perfil", "PersonalSettings": "Configuración personal", "UserDeletionConfirmationMessage": "El usuario '{0}' será eliminado. ¿Quieres continuar?", - "RoleDeletionConfirmationMessage": "El role '{0}' será eliminado. ¿Quieres continuar? ", - "DisplayName:RoleName": "Nombre de Role", + "RoleDeletionConfirmationMessage": "El rol '{0}' será eliminado. ¿Quieres continuar? ", + "DisplayName:RoleName": "Nombre de rol", "DisplayName:UserName": "Nombre de usuario", "DisplayName:Name": "Nombre", "DisplayName:Surname": "Apellido", @@ -26,8 +26,8 @@ "DisplayName:PhoneNumber": "Número de teléfono", "DisplayName:TwoFactorEnabled": "Autenticación en dos pasos", "DisplayName:LockoutEnabled": "Bloquear la cuenta después de intentos de inicio de sesión fallidos", - "NewRole": "Nuevo role", - "RoleName": "Nombre de role", + "NewRole": "Nuevo rol", + "RoleName": "Nombre de rol", "CreationTime": "Fecha de creación", "Permissions": "Permisos", "DisplayName:CurrentPassword": "Contraseña actual", @@ -38,12 +38,12 @@ "Volo.Abp.Identity:DefaultError": "Error desconocido.", "Volo.Abp.Identity:ConcurrencyFailure": "Fallo de concurrencia optimista", "Volo.Abp.Identity:DuplicateEmail": "E-mail '{0}' está en uso.", - "Volo.Abp.Identity:DuplicateRoleName": "Nombre de role '{0}' está en uso.", - "Volo.Abp.Identity:DuplicateUserName": "Nombre de usuario '{0}' está en uso.", + "Volo.Abp.Identity:DuplicateRoleName": "El nombre de rol '{0}' ya está en uso.", + "Volo.Abp.Identity:DuplicateUserName": "El nombre de usuario '{0}' ya está en uso.", "Volo.Abp.Identity:InvalidEmail": "E-mail '{0}' no es válido.", "Volo.Abp.Identity:InvalidPasswordHasherCompatibilityMode": "El PasswordHasherCompatibilityMode proporcionado no es válido.", "Volo.Abp.Identity:InvalidPasswordHasherIterationCount": "La cuenta iterativa debe ser una entero positivo.", - "Volo.Abp.Identity:InvalidRoleName": "El nombre de role '{0}' no es válido.", + "Volo.Abp.Identity:InvalidRoleName": "El nombre de rol '{0}' no es válido.", "Volo.Abp.Identity:InvalidToken": "token no válido", "Volo.Abp.Identity:InvalidUserName": "Nombre de usuario '{0}' no es válido. Sólo puede contener letras o dígitos", "Volo.Abp.Identity:LoginAlreadyAssociated": "Usuario con este inicio de sesión en uso.", @@ -53,7 +53,7 @@ "Volo.Abp.Identity:PasswordRequiresNonAlphanumeric": "Contraseñas deben tener al menos un carácter no alfanumérico", "Volo.Abp.Identity:PasswordRequiresUpper": "Contraseñas deben tener al menos un carácter en mayúsculas ('A'-'Z').", "Volo.Abp.Identity:PasswordTooShort": "Contraseñas deben tener al menos {0} caracteres", - "Volo.Abp.Identity:RoleNotFound": "El role {0} no existe.", + "Volo.Abp.Identity:RoleNotFound": "El rol {0} no existe.", "Volo.Abp.Identity:UserAlreadyHasPassword": "El usuario tiene la contraseña establecida", "Volo.Abp.Identity:UserAlreadyInRole": "El usuario ya tiene asignado el rol '{0}'´.", "Volo.Abp.Identity:UserLockedOut": "El usuario está bloqueado.", @@ -65,8 +65,8 @@ "Volo.Abp.Identity:010002": "No puedes establecer más de {MaxUserMembershipCount} unidades organizativas para un usuario!", "Volo.Abp.Identity:010003": "No puedes cambiar la contraseña de un usuario que inicio sesión desde un servicio externo!", "Volo.Abp.Identity:010004": "Hay una unidad organizativa con nombre {0}. Dos unidades con el mismo nombre no pueden ser creadas en el mismo nivel.", - "Volo.Abp.Identity:010005": "Roles estáticos no pueden ser renombrados.", - "Volo.Abp.Identity:010006": "Roles estáticos no pueden ser borrados.", + "Volo.Abp.Identity:010005": "Los roles estáticos no pueden ser renombrados.", + "Volo.Abp.Identity:010006": "Los roles estáticos no pueden ser borrados.", "Volo.Abp.Identity:010007": "No puedes cambiar tu configuración de autentificación de dos pasos.", "Volo.Abp.Identity:010008": "No está permitido cambiar la configuración de autenticación de dos pasos.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Número máximo de unidades organizativas por usuario", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo.Abp.Identity.EntityFrameworkCore.abppkg.json b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo.Abp.Identity.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo.Abp.Identity.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo.Abp.Identity.HttpApi.Client.abppkg.json b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo.Abp.Identity.HttpApi.Client.abppkg.json new file mode 100644 index 0000000000..7deef5e383 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo.Abp.Identity.HttpApi.Client.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api-client" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.abppkg.json b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.abppkg.json new file mode 100644 index 0000000000..515bfe64c4 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo.Abp.Identity.MongoDB.abppkg.json b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo.Abp.Identity.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo.Abp.Identity.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs index 2f48318511..a6355a794a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.Identity.Localization; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; namespace Volo.Abp.Identity.Web.Navigation { @@ -19,8 +20,8 @@ namespace Volo.Abp.Identity.Web.Navigation var l = context.GetLocalizer(); var identityMenuItem = new ApplicationMenuItem(IdentityMenuNames.GroupName, l["Menu:IdentityManagement"], icon: "fa fa-id-card-o"); - identityMenuItem.AddItem(new ApplicationMenuItem(IdentityMenuNames.Roles, l["Roles"], url: "~/Identity/Roles", requiredPermissionName: IdentityPermissions.Roles.Default)); - identityMenuItem.AddItem(new ApplicationMenuItem(IdentityMenuNames.Users, l["Users"], url: "~/Identity/Users", requiredPermissionName: IdentityPermissions.Users.Default)); + identityMenuItem.AddItem(new ApplicationMenuItem(IdentityMenuNames.Roles, l["Roles"], url: "~/Identity/Roles").RequirePermissions(IdentityPermissions.Roles.Default)); + identityMenuItem.AddItem(new ApplicationMenuItem(IdentityMenuNames.Users, l["Users"], url: "~/Identity/Users").RequirePermissions( IdentityPermissions.Users.Default)); context.Menu.GetAdministration().AddItem(identityMenuItem); diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.abppkg.json b/modules/identity/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.abppkg.json new file mode 100644 index 0000000000..930c4018b3 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mvc" +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo.Abp.PermissionManagement.Domain.Identity.abppkg.json b/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo.Abp.PermissionManagement.Domain.Identity.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo.Abp.PermissionManagement.Domain.Identity.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo.Abp.Identity.Application.Tests.abppkg.json b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo.Abp.Identity.Application.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo.Abp.Identity.Application.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo.Abp.Identity.AspNetCore.Tests.abppkg.json b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo.Abp.Identity.AspNetCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo.Abp.Identity.AspNetCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo.Abp.Identity.Domain.Tests.abppkg.json b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo.Abp.Identity.Domain.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo.Abp.Identity.Domain.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo.Abp.Identity.EntityFrameworkCore.Tests.abppkg.json b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo.Abp.Identity.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo.Abp.Identity.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo.Abp.Identity.MongoDB.Tests.abppkg.json b/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo.Abp.Identity.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo.Abp.Identity.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo.Abp.Identity.TestBase.abppkg.json b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo.Abp.Identity.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo.Abp.Identity.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/identityserver/Volo.Abp.IdentityServer.abpmdl.json b/modules/identityserver/Volo.Abp.IdentityServer.abpmdl.json index b56f99933a..01fe37ad9f 100644 --- a/modules/identityserver/Volo.Abp.IdentityServer.abpmdl.json +++ b/modules/identityserver/Volo.Abp.IdentityServer.abpmdl.json @@ -1,76 +1,46 @@ { "folders": { - "src": {}, - "test": {} - }, - "imports": { - "Volo.Abp.Identity": { - "path": "../identity/Volo.Abp.Identity.abpmdl.json" - }, - "Volo.Abp.PermissionManagement": { - "path": "../permission-management/Volo.Abp.PermissionManagement.abpmdl.json" + "items": { + "src": {}, + "test": {} } }, "packages": { - "Volo.Abp.IdentityServer.Domain.Shared": { - "path": "src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } - }, "Volo.Abp.IdentityServer.Domain": { - "path": "src/Volo.Abp.IdentityServer.Domain/Volo.Abp.IdentityServer.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.IdentityServer.Domain/Volo.Abp.IdentityServer.Domain.abppkg.json", + "folder": "src" + }, + "Volo.Abp.IdentityServer.Domain.Shared": { + "path": "src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.IdentityServer.EntityFrameworkCore": { - "path": "src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo.Abp.IdentityServer.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo.Abp.IdentityServer.EntityFrameworkCore.abppkg.json", + "folder": "src" }, - "Volo.Abp.IdentityServer.MongoDB": { - "path": "src/Volo.Abp.IdentityServer.MongoDB/Volo.Abp.IdentityServer.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } + "Volo.Abp.IdentityServer.EntityFrameworkCore.Tests": { + "path": "test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.PermissionManagement.Domain.IdentityServer": { - "path": "src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo.Abp.PermissionManagement.Domain.IdentityServer.csproj", + "Volo.Abp.IdentityServer.MongoDB": { + "path": "src/Volo.Abp.IdentityServer.MongoDB/Volo.Abp.IdentityServer.MongoDB.abppkg.json", "folder": "src" }, "Volo.Abp.IdentityServer.TestBase": { - "path": "test/Volo.Abp.IdentityServer.TestBase/Volo.Abp.IdentityServer.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "test/Volo.Abp.IdentityServer.TestBase/Volo.Abp.IdentityServer.TestBase.abppkg.json", + "folder": "test" }, - "Volo.Abp.IdentityServer.Domain.Tests": { - "path": "test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.IdentityServer.MongoDB.Tests": { + "path": "test/Volo.Abp.IdentityServer.MongoDB.Tests/Volo.Abp.IdentityServer.MongoDB.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.IdentityServer.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.IdentityServer.Domain.Tests": { + "path": "test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.abppkg.json", + "folder": "test" }, - "Volo.Abp.IdentityServer.MongoDB.Tests": { - "path": "test/Volo.Abp.IdentityServer.MongoDB.Tests/Volo.Abp.IdentityServer.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.PermissionManagement.Domain.IdentityServer": { + "path": "src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo.Abp.PermissionManagement.Domain.IdentityServer.abppkg.json", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.abppkg.json b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo.Abp.IdentityServer.Domain.abppkg.json b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo.Abp.IdentityServer.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo.Abp.IdentityServer.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator.cs index 359babde7e..a4459d99e2 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using IdentityServer4.Models; using IdentityServer4.Validation; @@ -33,7 +34,9 @@ namespace Volo.Abp.IdentityServer var extractResult = FormattedStringValueExtracter.Extract(requestedUri, url, ignoreCase: true); if (extractResult.IsMatch) { - return Task.FromResult(true); + return Task.FromResult(extractResult.Matches + .Aggregate(url, (current, nameValue) => current.Replace($"{{{nameValue.Name}}}", nameValue.Value)) + .Contains(requestedUri, StringComparison.OrdinalIgnoreCase)); } if (url.Replace("{0}.", "").Contains(requestedUri, StringComparison.OrdinalIgnoreCase)) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService.cs index 1a9d146ca9..daf8d1f6f2 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; using IdentityServer4.Configuration; using Microsoft.Extensions.Options; @@ -32,7 +33,8 @@ namespace Volo.Abp.IdentityServer var extractResult = FormattedStringValueExtracter.Extract(origin, url, ignoreCase: true); if (extractResult.IsMatch) { - return true; + return extractResult.Matches.Aggregate(url, (current, nameValue) => current.Replace($"{{{nameValue.Name}}}", nameValue.Value)) + .Contains(origin, StringComparison.OrdinalIgnoreCase); } if (url.Replace("{0}.", "").Contains(origin, StringComparison.OrdinalIgnoreCase)) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo.Abp.IdentityServer.EntityFrameworkCore.abppkg.json b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo.Abp.IdentityServer.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo.Abp.IdentityServer.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo.Abp.IdentityServer.MongoDB.abppkg.json b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo.Abp.IdentityServer.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo.Abp.IdentityServer.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo.Abp.PermissionManagement.Domain.IdentityServer.abppkg.json b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo.Abp.PermissionManagement.Domain.IdentityServer.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo.Abp.PermissionManagement.Domain.IdentityServer.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.abppkg.json b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator_Tests.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator_Tests.cs index a455cd9811..7f00d2e355 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator_Tests.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpStrictRedirectUriValidator_Tests.cs @@ -54,6 +54,7 @@ namespace Volo.Abp.IdentityServer (await _abpStrictRedirectUriValidator.IsRedirectUriValidAsync("http://ng.abp.io", _testClient)).ShouldBeTrue(); (await _abpStrictRedirectUriValidator.IsRedirectUriValidAsync("https://api.t1.abp:8080/", _testClient)).ShouldBeFalse(); (await _abpStrictRedirectUriValidator.IsRedirectUriValidAsync("http://ng.t1.abp.io", _testClient)).ShouldBeFalse(); + (await _abpStrictRedirectUriValidator.IsRedirectUriValidAsync("http://t1.ng.abp.io/index.html.mydomain.com", _testClient)).ShouldBeFalse(); } [Fact] @@ -68,6 +69,7 @@ namespace Volo.Abp.IdentityServer (await _abpStrictRedirectUriValidator.IsPostLogoutRedirectUriValidAsync("http://ng.abp.io", _testClient)).ShouldBeTrue(); (await _abpStrictRedirectUriValidator.IsPostLogoutRedirectUriValidAsync("https://api.t1.abp:8080/", _testClient)).ShouldBeFalse(); (await _abpStrictRedirectUriValidator.IsPostLogoutRedirectUriValidAsync("http://ng.t1.abp.io", _testClient)).ShouldBeFalse(); + (await _abpStrictRedirectUriValidator.IsPostLogoutRedirectUriValidAsync("http://t1.ng.abp.io/index.html.mydomain.com", _testClient)).ShouldBeFalse(); } } } diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService_Tests.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService_Tests.cs index fcb8e756e0..36949582d7 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService_Tests.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpWildcardSubdomainCorsPolicyService_Tests.cs @@ -35,6 +35,8 @@ namespace Volo.Abp.IdentityServer (await _corsPolicyService.IsOriginAllowedAsync("https://abp.io")).ShouldBeTrue(); (await _corsPolicyService.IsOriginAllowedAsync("https://t1.abp.io")).ShouldBeTrue(); (await _corsPolicyService.IsOriginAllowedAsync("https://t1.ng.abp.io")).ShouldBeTrue(); + + (await _corsPolicyService.IsOriginAllowedAsync("https://t1.abp.io.mydomain.com")).ShouldBeFalse(); } } } diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.abppkg.json b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.MongoDB.Tests/Volo.Abp.IdentityServer.MongoDB.Tests.abppkg.json b/modules/identityserver/test/Volo.Abp.IdentityServer.MongoDB.Tests/Volo.Abp.IdentityServer.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.MongoDB.Tests/Volo.Abp.IdentityServer.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo.Abp.IdentityServer.TestBase.abppkg.json b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo.Abp.IdentityServer.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo.Abp.IdentityServer.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/permission-management/Volo.Abp.PermissionManagement.abpmdl.json b/modules/permission-management/Volo.Abp.PermissionManagement.abpmdl.json index b0c0b4ebb7..82dc87dade 100644 --- a/modules/permission-management/Volo.Abp.PermissionManagement.abpmdl.json +++ b/modules/permission-management/Volo.Abp.PermissionManagement.abpmdl.json @@ -1,127 +1,78 @@ { "folders": { - "src": {}, - "test": {} + "items": { + "src": {}, + "test": {} + } }, "packages": { "Volo.Abp.PermissionManagement.Domain.Shared": { - "path": "src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.Domain": { - "path": "src/Volo.Abp.PermissionManagement.Domain/Volo.Abp.PermissionManagement.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } + "path": "src/Volo.Abp.PermissionManagement.Domain/Volo.Abp.PermissionManagement.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.Application.Contracts": { - "path": "src/Volo.Abp.PermissionManagement.Application.Contracts/Volo.Abp.PermissionManagement.Application.Contracts.csproj", - "folder": "src", - "includes": { - "lib.application.contracts": {} - } + "path": "src/Volo.Abp.PermissionManagement.Application.Contracts/Volo.Abp.PermissionManagement.Application.Contracts.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.Application": { - "path": "src/Volo.Abp.PermissionManagement.Application/Volo.Abp.PermissionManagement.Application.csproj", - "folder": "src", - "includes": { - "lib.application": {} - } + "path": "src/Volo.Abp.PermissionManagement.Application/Volo.Abp.PermissionManagement.Application.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.EntityFrameworkCore": { - "path": "src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo.Abp.PermissionManagement.EntityFrameworkCore.abppkg.json", + "folder": "src" + }, + "Volo.Abp.PermissionManagement.Web": { + "path": "src/Volo.Abp.PermissionManagement.Web/Volo.Abp.PermissionManagement.Web.abppkg.json", + "folder": "src" + }, + "Volo.Abp.PermissionManagement.Domain.Tests": { + "path": "test/Volo.Abp.PermissionManagement.Domain.Tests/Volo.Abp.PermissionManagement.Domain.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.PermissionManagement.TestBase": { + "path": "test/Volo.Abp.PermissionManagement.TestBase/Volo.Abp.PermissionManagement.TestBase.abppkg.json", + "folder": "test" + }, + "Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests": { + "path": "test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.PermissionManagement.MongoDB": { - "path": "src/Volo.Abp.PermissionManagement.MongoDB/Volo.Abp.PermissionManagement.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } + "path": "src/Volo.Abp.PermissionManagement.MongoDB/Volo.Abp.PermissionManagement.MongoDB.abppkg.json", + "folder": "src" + }, + "Volo.Abp.PermissionManagement.MongoDB.Tests": { + "path": "test/Volo.Abp.PermissionManagement.MongoDB.Tests/Volo.Abp.PermissionManagement.MongoDB.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.PermissionManagement.HttpApi": { - "path": "src/Volo.Abp.PermissionManagement.HttpApi/Volo.Abp.PermissionManagement.HttpApi.csproj", - "folder": "src", - "includes": { - "lib.http-api": {} - } + "path": "src/Volo.Abp.PermissionManagement.HttpApi/Volo.Abp.PermissionManagement.HttpApi.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.HttpApi.Client": { - "path": "src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo.Abp.PermissionManagement.HttpApi.Client.csproj", - "folder": "src", - "includes": { - "lib.http-api-client": {} - } + "path": "src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo.Abp.PermissionManagement.HttpApi.Client.abppkg.json", + "folder": "src" }, - "Volo.Abp.PermissionManagement.Web": { - "path": "src/Volo.Abp.PermissionManagement.Web/Volo.Abp.PermissionManagement.Web.csproj", - "folder": "src", - "includes": { - "lib.ui.mvc": {} - } + "Volo.Abp.PermissionManagement.Application.Tests": { + "path": "test/Volo.Abp.PermissionManagement.Application.Tests/Volo.Abp.PermissionManagement.Application.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.PermissionManagement.Blazor": { - "path": "src/Volo.Abp.PermissionManagement.Blazor/Volo.Abp.PermissionManagement.Blazor.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor": {} - } + "path": "src/Volo.Abp.PermissionManagement.Blazor/Volo.Abp.PermissionManagement.Blazor.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.Blazor.Server": { - "path": "src/Volo.Abp.PermissionManagement.Blazor.Server/Volo.Abp.PermissionManagement.Blazor.Server.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-server": {} - } + "path": "src/Volo.Abp.PermissionManagement.Blazor.Server/Volo.Abp.PermissionManagement.Blazor.Server.abppkg.json", + "folder": "src" }, "Volo.Abp.PermissionManagement.Blazor.WebAssembly": { - "path": "src/Volo.Abp.PermissionManagement.Blazor.WebAssembly/Volo.Abp.PermissionManagement.Blazor.WebAssembly.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-wasm": {} - } - }, - "Volo.Abp.PermissionManagement.TestBase": { - "path": "test/Volo.Abp.PermissionManagement.TestBase/Volo.Abp.PermissionManagement.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.PermissionManagement.Domain.Tests": { - "path": "test/Volo.Abp.PermissionManagement.Domain.Tests/Volo.Abp.PermissionManagement.Domain.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.PermissionManagement.MongoDB.Tests": { - "path": "test/Volo.Abp.PermissionManagement.MongoDB.Tests/Volo.Abp.PermissionManagement.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } - }, - "Volo.Abp.PermissionManagement.Application.Tests": { - "path": "test/Volo.Abp.PermissionManagement.Application.Tests/Volo.Abp.PermissionManagement.Application.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "path": "src/Volo.Abp.PermissionManagement.Blazor.WebAssembly/Volo.Abp.PermissionManagement.Blazor.WebAssembly.abppkg.json", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo.Abp.PermissionManagement.Application.Contracts.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo.Abp.PermissionManagement.Application.Contracts.abppkg.json new file mode 100644 index 0000000000..49032794e2 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo.Abp.PermissionManagement.Application.Contracts.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application-contracts" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo.Abp.PermissionManagement.Application.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo.Abp.PermissionManagement.Application.abppkg.json new file mode 100644 index 0000000000..412567ac33 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo.Abp.PermissionManagement.Application.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs index 4bc73a6f86..abcbcd6a48 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Options; using Volo.Abp.Application.Services; using Volo.Abp.Authorization.Permissions; using Volo.Abp.MultiTenancy; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.PermissionManagement { @@ -16,18 +17,18 @@ namespace Volo.Abp.PermissionManagement protected PermissionManagementOptions Options { get; } protected IPermissionManager PermissionManager { get; } protected IPermissionDefinitionManager PermissionDefinitionManager { get; } - protected IPermissionStateManager PermissionStateManager { get; } + protected ISimpleStateCheckerManager SimpleStateCheckerManager { get; } public PermissionAppService( IPermissionManager permissionManager, IPermissionDefinitionManager permissionDefinitionManager, IOptions options, - IPermissionStateManager permissionStateManager) + ISimpleStateCheckerManager simpleStateCheckerManager) { Options = options.Value; PermissionManager = permissionManager; PermissionDefinitionManager = permissionDefinitionManager; - PermissionStateManager = permissionStateManager; + SimpleStateCheckerManager = simpleStateCheckerManager; } public virtual async Task GetAsync(string providerName, string providerKey) @@ -58,7 +59,7 @@ namespace Volo.Abp.PermissionManagement continue; } - if (!await PermissionStateManager.IsEnabledAsync(permission)) + if (!await SimpleStateCheckerManager.IsEnabledAsync(permission)) { continue; } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.Server/Volo.Abp.PermissionManagement.Blazor.Server.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.Server/Volo.Abp.PermissionManagement.Blazor.Server.abppkg.json new file mode 100644 index 0000000000..ef40d81585 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.Server/Volo.Abp.PermissionManagement.Blazor.Server.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-server" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.WebAssembly/Volo.Abp.PermissionManagement.Blazor.WebAssembly.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.WebAssembly/Volo.Abp.PermissionManagement.Blazor.WebAssembly.abppkg.json new file mode 100644 index 0000000000..471ef5e067 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor.WebAssembly/Volo.Abp.PermissionManagement.Blazor.WebAssembly.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-wasm" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor/Volo.Abp.PermissionManagement.Blazor.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor/Volo.Abp.PermissionManagement.Blazor.abppkg.json new file mode 100644 index 0000000000..19c29b7b8b --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor/Volo.Abp.PermissionManagement.Blazor.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo.Abp.PermissionManagement.Domain.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo.Abp.PermissionManagement.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo.Abp.PermissionManagement.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs index c178a6ae0e..d0ee7c4853 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs @@ -9,6 +9,7 @@ using Volo.Abp.Caching; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; using Volo.Abp.MultiTenancy; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.PermissionManagement { @@ -18,7 +19,7 @@ namespace Volo.Abp.PermissionManagement protected IPermissionDefinitionManager PermissionDefinitionManager { get; } - protected IPermissionStateManager PermissionStateManager { get; } + protected ISimpleStateCheckerManager SimpleStateCheckerManager { get; } protected IGuidGenerator GuidGenerator { get; } @@ -34,7 +35,7 @@ namespace Volo.Abp.PermissionManagement public PermissionManager( IPermissionDefinitionManager permissionDefinitionManager, - IPermissionStateManager permissionStateManager, + ISimpleStateCheckerManager simpleStateCheckerManager, IPermissionGrantRepository permissionGrantRepository, IServiceProvider serviceProvider, IGuidGenerator guidGenerator, @@ -45,7 +46,7 @@ namespace Volo.Abp.PermissionManagement GuidGenerator = guidGenerator; CurrentTenant = currentTenant; Cache = cache; - PermissionStateManager = permissionStateManager; + SimpleStateCheckerManager = simpleStateCheckerManager; PermissionGrantRepository = permissionGrantRepository; PermissionDefinitionManager = permissionDefinitionManager; Options = options.Value; @@ -80,7 +81,7 @@ namespace Volo.Abp.PermissionManagement { var permission = PermissionDefinitionManager.Get(permissionName); - if (!permission.IsEnabled || !await PermissionStateManager.IsEnabledAsync(permission)) + if (!permission.IsEnabled || !await SimpleStateCheckerManager.IsEnabledAsync(permission)) { //TODO: BusinessException throw new ApplicationException($"The permission named '{permission.Name}' is disabled!"); @@ -150,7 +151,7 @@ namespace Volo.Abp.PermissionManagement return result; } - if (!await PermissionStateManager.IsEnabledAsync(permission)) + if (!await SimpleStateCheckerManager.IsEnabledAsync(permission)) { return result; } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo.Abp.PermissionManagement.EntityFrameworkCore.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo.Abp.PermissionManagement.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo.Abp.PermissionManagement.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo.Abp.PermissionManagement.HttpApi.Client.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo.Abp.PermissionManagement.HttpApi.Client.abppkg.json new file mode 100644 index 0000000000..7deef5e383 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo.Abp.PermissionManagement.HttpApi.Client.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api-client" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo.Abp.PermissionManagement.HttpApi.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo.Abp.PermissionManagement.HttpApi.abppkg.json new file mode 100644 index 0000000000..515bfe64c4 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo.Abp.PermissionManagement.HttpApi.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo.Abp.PermissionManagement.MongoDB.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo.Abp.PermissionManagement.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo.Abp.PermissionManagement.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Volo.Abp.PermissionManagement.Web.abppkg.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Volo.Abp.PermissionManagement.Web.abppkg.json new file mode 100644 index 0000000000..930c4018b3 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Volo.Abp.PermissionManagement.Web.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mvc" +} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.Application.Tests/Volo.Abp.PermissionManagement.Application.Tests.abppkg.json b/modules/permission-management/test/Volo.Abp.PermissionManagement.Application.Tests/Volo.Abp.PermissionManagement.Application.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.Application.Tests/Volo.Abp.PermissionManagement.Application.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.Domain.Tests/Volo.Abp.PermissionManagement.Domain.Tests.abppkg.json b/modules/permission-management/test/Volo.Abp.PermissionManagement.Domain.Tests/Volo.Abp.PermissionManagement.Domain.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.Domain.Tests/Volo.Abp.PermissionManagement.Domain.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg.json b/modules/permission-management/test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.MongoDB.Tests/Volo.Abp.PermissionManagement.MongoDB.Tests.abppkg.json b/modules/permission-management/test/Volo.Abp.PermissionManagement.MongoDB.Tests/Volo.Abp.PermissionManagement.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.MongoDB.Tests/Volo.Abp.PermissionManagement.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo.Abp.PermissionManagement.TestBase.abppkg.json b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo.Abp.PermissionManagement.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo.Abp.PermissionManagement.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs index d2256a5868..f01961d24c 100644 --- a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.PermissionManagement testGroup.AddPermission("MyPermission4", multiTenancySide: MultiTenancySides.Host).WithProviders(UserPermissionValueProvider.ProviderName); - testGroup.AddPermission("MyPermission5").AddStateProviders(new TestRequireRolePermissionStateProvider("super-admin")); + testGroup.AddPermission("MyPermission5").StateCheckers.Add(new TestRequireRolePermissionStateProvider("super-admin")); } } } diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestRequireRolePermissionStateProvider.cs b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestRequireRolePermissionStateProvider.cs index 56e34f2894..3531479b43 100644 --- a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestRequireRolePermissionStateProvider.cs +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestRequireRolePermissionStateProvider.cs @@ -4,10 +4,11 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Security.Claims; +using Volo.Abp.SimpleStateChecking; namespace Volo.Abp.PermissionManagement { - public class TestRequireRolePermissionStateProvider : IPermissionStateProvider + public class TestRequireRolePermissionStateProvider : ISimpleStateChecker { private readonly List _allowRoles = new List(); @@ -16,7 +17,7 @@ namespace Volo.Abp.PermissionManagement _allowRoles.AddRange(roles); } - public Task IsEnabledAsync(PermissionStateContext context) + public Task IsEnabledAsync(SimpleStateCheckerContext context) { var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService(); return Task.FromResult(currentPrincipalAccessor.Principal != null && _allowRoles.Any(role => currentPrincipalAccessor.Principal.IsInRole(role))); diff --git a/modules/setting-management/Volo.Abp.SettingManagement.abpmdl.json b/modules/setting-management/Volo.Abp.SettingManagement.abpmdl.json index 8181f78b91..899d1a00ed 100644 --- a/modules/setting-management/Volo.Abp.SettingManagement.abpmdl.json +++ b/modules/setting-management/Volo.Abp.SettingManagement.abpmdl.json @@ -1,120 +1,79 @@ { "folders": { - "src": {}, - "test": {} + "items": { + "src": {}, + "test": {}, + "app": {} + } }, "packages": { "Volo.Abp.SettingManagement.Domain.Shared": { - "path": "src/Volo.Abp.SettingManagement.Domain.Shared/Volo.Abp.SettingManagement.Domain.Shared.csproj", - "folder": "src", - "includes": { - "lib.domain.shared": {} - } + "path": "src/Volo.Abp.SettingManagement.Domain.Shared/Volo.Abp.SettingManagement.Domain.Shared.abppkg.json", + "folder": "src" }, "Volo.Abp.SettingManagement.Domain": { - "path": "src/Volo.Abp.SettingManagement.Domain/Volo.Abp.SettingManagement.Domain.csproj", - "folder": "src", - "includes": { - "lib.domain": {} - } - }, - "Volo.Abp.SettingManagement.Application.Contracts": { - "path": "src/Volo.Abp.SettingManagement.Application.Contracts/Volo.Abp.SettingManagement.Application.Contracts.csproj", - "folder": "src", - "includes": { - "lib.application.contracts": {} - } - }, - "Volo.Abp.SettingManagement.Application": { - "path": "src/Volo.Abp.SettingManagement.Application/Volo.Abp.SettingManagement.Application.csproj", - "folder": "src", - "includes": { - "lib.application": {} - } + "path": "src/Volo.Abp.SettingManagement.Domain/Volo.Abp.SettingManagement.Domain.abppkg.json", + "folder": "src" }, "Volo.Abp.SettingManagement.EntityFrameworkCore": { - "path": "src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.csproj", - "folder": "src", - "includes": { - "lib.ef": {} - } + "path": "src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.abppkg.json", + "folder": "src" + }, + "Volo.Abp.SettingManagement.Tests": { + "path": "test/Volo.Abp.SettingManagement.Tests/Volo.Abp.SettingManagement.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.SettingManagement.MongoDB": { - "path": "src/Volo.Abp.SettingManagement.MongoDB/Volo.Abp.SettingManagement.MongoDB.csproj", - "folder": "src", - "includes": { - "lib.mongodb": {} - } + "path": "src/Volo.Abp.SettingManagement.MongoDB/Volo.Abp.SettingManagement.MongoDB.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.HttpApi": { - "path": "src/Volo.Abp.SettingManagement.HttpApi/Volo.Abp.SettingManagement.HttpApi.csproj", - "folder": "src", - "includes": { - "lib.http-api": {} - } + "Volo.Abp.SettingManagement.TestBase": { + "path": "test/Volo.Abp.SettingManagement.TestBase/Volo.Abp.SettingManagement.TestBase.abppkg.json", + "folder": "test" }, - "Volo.Abp.SettingManagement.HttpApi.Client": { - "path": "src/Volo.Abp.SettingManagement.HttpApi.Client/Volo.Abp.SettingManagement.HttpApi.Client.csproj", - "folder": "src", - "includes": { - "lib.http-api-client": {} - } + "Volo.Abp.SettingManagement.EntityFrameworkCore.Tests": { + "path": "test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests.abppkg.json", + "folder": "test" + }, + "Volo.Abp.SettingManagement.MongoDB.Tests": { + "path": "test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo.Abp.SettingManagement.MongoDB.Tests.abppkg.json", + "folder": "test" }, "Volo.Abp.SettingManagement.Web": { - "path": "src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj", - "folder": "src", - "includes": { - "lib.ui.mvc": {} - } + "path": "src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.abppkg.json", + "folder": "src" }, "Volo.Abp.SettingManagement.Blazor": { - "path": "src/Volo.Abp.SettingManagement.Blazor/Volo.Abp.SettingManagement.Blazor.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor": {} - } + "path": "src/Volo.Abp.SettingManagement.Blazor/Volo.Abp.SettingManagement.Blazor.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.Blazor.Server": { - "path": "src/Volo.Abp.SettingManagement.Blazor.Server/Volo.Abp.SettingManagement.Blazor.Server.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-server": {} - } + "Volo.Abp.SettingManagement.Application": { + "path": "src/Volo.Abp.SettingManagement.Application/Volo.Abp.SettingManagement.Application.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.Blazor.WebAssembly": { - "path": "src/Volo.Abp.SettingManagement.Blazor.WebAssembly/Volo.Abp.SettingManagement.Blazor.WebAssembly.csproj", - "folder": "src", - "includes": { - "lib.ui.blazor-wasm": {} - } + "Volo.Abp.SettingManagement.Application.Contracts": { + "path": "src/Volo.Abp.SettingManagement.Application.Contracts/Volo.Abp.SettingManagement.Application.Contracts.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.TestBase": { - "path": "test/Volo.Abp.SettingManagement.TestBase/Volo.Abp.SettingManagement.TestBase.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.SettingManagement.HttpApi": { + "path": "src/Volo.Abp.SettingManagement.HttpApi/Volo.Abp.SettingManagement.HttpApi.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.Tests": { - "path": "test/Volo.Abp.SettingManagement.Tests/Volo.Abp.SettingManagement.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.SettingManagement.HttpApi.Client": { + "path": "src/Volo.Abp.SettingManagement.HttpApi.Client/Volo.Abp.SettingManagement.HttpApi.Client.abppkg.json", + "folder": "src" }, - "Volo.Abp.SettingManagement.EntityFrameworkCore.Tests": { - "path": "test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.SettingManagement.DemoApp": { + "path": "app/Volo.Abp.SettingManagement.DemoApp/Volo.Abp.SettingManagement.DemoApp.abppkg.json", + "folder": "app" }, - "Volo.Abp.SettingManagement.MongoDB.Tests": { - "path": "test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo.Abp.SettingManagement.MongoDB.Tests.csproj", - "folder": "test", - "includes": { - "lib.test": {} - } + "Volo.Abp.SettingManagement.Blazor.Server": { + "path": "src/Volo.Abp.SettingManagement.Blazor.Server/Volo.Abp.SettingManagement.Blazor.Server.abppkg.json", + "folder": "src" + }, + "Volo.Abp.SettingManagement.Blazor.WebAssembly": { + "path": "src/Volo.Abp.SettingManagement.Blazor.WebAssembly/Volo.Abp.SettingManagement.Blazor.WebAssembly.abppkg.json", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Volo.Abp.SettingManagement.DemoApp.abppkg.json b/modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Volo.Abp.SettingManagement.DemoApp.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Volo.Abp.SettingManagement.DemoApp.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo.Abp.SettingManagement.Application.Contracts.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo.Abp.SettingManagement.Application.Contracts.abppkg.json new file mode 100644 index 0000000000..49032794e2 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo.Abp.SettingManagement.Application.Contracts.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application-contracts" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo.Abp.SettingManagement.Application.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo.Abp.SettingManagement.Application.abppkg.json new file mode 100644 index 0000000000..412567ac33 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo.Abp.SettingManagement.Application.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.application" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.Server/Volo.Abp.SettingManagement.Blazor.Server.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.Server/Volo.Abp.SettingManagement.Blazor.Server.abppkg.json new file mode 100644 index 0000000000..ef40d81585 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.Server/Volo.Abp.SettingManagement.Blazor.Server.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-server" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.WebAssembly/Volo.Abp.SettingManagement.Blazor.WebAssembly.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.WebAssembly/Volo.Abp.SettingManagement.Blazor.WebAssembly.abppkg.json new file mode 100644 index 0000000000..471ef5e067 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.WebAssembly/Volo.Abp.SettingManagement.Blazor.WebAssembly.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor-wasm" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Volo.Abp.SettingManagement.Blazor.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Volo.Abp.SettingManagement.Blazor.abppkg.json new file mode 100644 index 0000000000..19c29b7b8b --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Volo.Abp.SettingManagement.Blazor.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.blazor" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo.Abp.SettingManagement.Domain.Shared.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo.Abp.SettingManagement.Domain.Shared.abppkg.json new file mode 100644 index 0000000000..8b3de05f76 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo.Abp.SettingManagement.Domain.Shared.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo.Abp.SettingManagement.Domain.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo.Abp.SettingManagement.Domain.abppkg.json new file mode 100644 index 0000000000..1d574efe45 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo.Abp.SettingManagement.Domain.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.abppkg.json new file mode 100644 index 0000000000..e1c64f0175 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo.Abp.SettingManagement.EntityFrameworkCore.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/Volo.Abp.SettingManagement.HttpApi.Client.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/Volo.Abp.SettingManagement.HttpApi.Client.abppkg.json new file mode 100644 index 0000000000..7deef5e383 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/Volo.Abp.SettingManagement.HttpApi.Client.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api-client" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo.Abp.SettingManagement.HttpApi.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo.Abp.SettingManagement.HttpApi.abppkg.json new file mode 100644 index 0000000000..515bfe64c4 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo.Abp.SettingManagement.HttpApi.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo.Abp.SettingManagement.MongoDB.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo.Abp.SettingManagement.MongoDB.abppkg.json new file mode 100644 index 0000000000..8b23fd1e69 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo.Abp.SettingManagement.MongoDB.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.abppkg.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.abppkg.json new file mode 100644 index 0000000000..930c4018b3 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.mvc" +} \ No newline at end of file diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests.abppkg.json b/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo.Abp.SettingManagement.MongoDB.Tests.abppkg.json b/modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo.Abp.SettingManagement.MongoDB.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo.Abp.SettingManagement.MongoDB.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo.Abp.SettingManagement.TestBase.abppkg.json b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo.Abp.SettingManagement.TestBase.abppkg.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo.Abp.SettingManagement.TestBase.abppkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo.Abp.SettingManagement.Tests.abppkg.json b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo.Abp.SettingManagement.Tests.abppkg.json new file mode 100644 index 0000000000..a686451fbc --- /dev/null +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo.Abp.SettingManagement.Tests.abppkg.json @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Navigation/TenantManagementBlazorMenuContributor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Navigation/TenantManagementBlazorMenuContributor.cs index 3f4fa8683c..193cfb034b 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Navigation/TenantManagementBlazorMenuContributor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Navigation/TenantManagementBlazorMenuContributor.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Volo.Abp.TenantManagement.Localization; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; namespace Volo.Abp.TenantManagement.Blazor.Navigation { @@ -27,9 +28,8 @@ namespace Volo.Abp.TenantManagement.Blazor.Navigation tenantManagementMenuItem.AddItem(new ApplicationMenuItem( TenantManagementMenuNames.Tenants, l["Tenants"], - url: "~/tenant-management/tenants", - requiredPermissionName: TenantManagementPermissions.Tenants.Default - )); + url: "~/tenant-management/tenants" + ).RequirePermissions(TenantManagementPermissions.Tenants.Default)); return Task.CompletedTask; } diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs index 31eb7c6d19..539cafb4bb 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs @@ -22,7 +22,8 @@ namespace Volo.Abp.TenantManagement return connStrings; }); - }); + }) + .ForMember(x => x.IsActive, x => x.Ignore()); CreateMap(); } diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs index c3ebaa39b5..1cc917c311 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.TenantManagement.Localization; using Volo.Abp.UI.Navigation; +using Volo.Abp.Authorization.Permissions; namespace Volo.Abp.TenantManagement.Web.Navigation { @@ -23,7 +24,7 @@ namespace Volo.Abp.TenantManagement.Web.Navigation var tenantManagementMenuItem = new ApplicationMenuItem(TenantManagementMenuNames.GroupName, l["Menu:TenantManagement"], icon: "fa fa-users"); administrationMenu.AddItem(tenantManagementMenuItem); - tenantManagementMenuItem.AddItem(new ApplicationMenuItem(TenantManagementMenuNames.Tenants, l["Tenants"], url: "~/TenantManagement/Tenants", requiredPermissionName: TenantManagementPermissions.Tenants.Default)); + tenantManagementMenuItem.AddItem(new ApplicationMenuItem(TenantManagementMenuNames.Tenants, l["Tenants"], url: "~/TenantManagement/Tenants").RequirePermissions(TenantManagementPermissions.Tenants.Default)); return Task.CompletedTask; } diff --git a/modules/users/Volo.Abp.Users.abpmdl.json b/modules/users/Volo.Abp.Users.abpmdl.json index 63ec84a14e..f2b03eef4f 100644 --- a/modules/users/Volo.Abp.Users.abpmdl.json +++ b/modules/users/Volo.Abp.Users.abpmdl.json @@ -5,14 +5,6 @@ } }, "packages": { - "Volo.Abp.Users.Abstractions": { - "path": "src/Volo.Abp.Users.Abstractions/Volo.Abp.Users.Abstractions.abppkg.json", - "folder": "src" - }, - "Volo.Abp.Users.Domain.Shared": { - "path": "src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json", - "folder": "src" - }, "Volo.Abp.Users.Domain": { "path": "src/Volo.Abp.Users.Domain/Volo.Abp.Users.Domain.abppkg.json", "folder": "src" @@ -21,6 +13,14 @@ "path": "src/Volo.Abp.Users.EntityFrameworkCore/Volo.Abp.Users.EntityFrameworkCore.abppkg.json", "folder": "src" }, + "Volo.Abp.Users.Domain.Shared": { + "path": "src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json", + "folder": "src" + }, + "Volo.Abp.Users.Abstractions": { + "path": "src/Volo.Abp.Users.Abstractions/Volo.Abp.Users.Abstractions.abppkg.json", + "folder": "src" + }, "Volo.Abp.Users.MongoDB": { "path": "src/Volo.Abp.Users.MongoDB/Volo.Abp.Users.MongoDB.abppkg.json", "folder": "src" diff --git a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json index 169c71c1e1..8b3de05f76 100644 --- a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json +++ b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo.Abp.Users.Domain.Shared.abppkg.json @@ -1,3 +1,3 @@ { - "role": "lib.domain.shared" + "role": "lib.domain-shared" } \ No newline at end of file diff --git a/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts index 4e4313caf5..b130afcc23 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts @@ -12,7 +12,6 @@ describe('LocalizationService', () => { let spectator: SpectatorService; let sessionState: SpyObject; let configState: SpyObject; - let router: SpyObject; let service: LocalizationService; const createService = createServiceFactory({ diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/tests/enum.util.spec.ts b/npm/ng-packs/packages/theme-shared/extensions/src/tests/enum.util.spec.ts index c757fad1e5..6c9ffeaa38 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/tests/enum.util.spec.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/tests/enum.util.spec.ts @@ -110,5 +110,5 @@ function createMockLocalizationService() { const configState = new ConfigStateService(); configState.setState({ localization: mockL10n } as any); - return new LocalizationService(mockSessionState, null, null, null, configState, null); + return new LocalizationService(mockSessionState, null, null, configState, null); } diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/datepicker-config.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/datepicker-config.ts new file mode 100644 index 0000000000..6fc30c8577 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/datepicker-config.ts @@ -0,0 +1,11 @@ +import { Injector } from '@angular/core'; +import { NgbInputDatepickerConfig } from '@ng-bootstrap/ng-bootstrap'; + +export function initDatepickerConfig(injector: Injector) { + const datepickerConfig = injector.get(NgbInputDatepickerConfig, null); + if (datepickerConfig) { + datepickerConfig.container = 'body'; + } + + return () => {}; +} diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts index 11eb07398e..a9253984b5 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts @@ -1,2 +1,3 @@ export * from './error.handler'; export * from './lazy-style.handler'; +export * from './datepicker-config'; diff --git a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts index ddf1d6a5a3..72b99aa7e4 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts @@ -38,6 +38,7 @@ import { THEME_SHARED_APPEND_CONTENT } from './tokens/append-content.token'; import { HTTP_ERROR_CONFIG, httpErrorConfigFactory } from './tokens/http-error.token'; import { DateParserFormatter } from './utils/date-parser-formatter'; import { ModalCloseDirective } from './components/modal/modal-close.directive'; +import { initDatepickerConfig } from './handlers/datepicker-config'; const declarationsWithExports = [ BreadcrumbComponent, @@ -110,6 +111,12 @@ export class ThemeSharedModule { deps: [Injector], useFactory: initLazyStyleHandler, }, + { + provide: APP_INITIALIZER, + multi: true, + deps: [Injector], + useFactory: initDatepickerConfig, + }, { provide: HTTP_ERROR_CONFIG, useValue: httpErrorConfig }, { provide: 'HTTP_ERROR_CONFIG', diff --git a/npm/ng-packs/packages/theme-shared/src/public-api.ts b/npm/ng-packs/packages/theme-shared/src/public-api.ts index 5a4f9efe95..845655402d 100644 --- a/npm/ng-packs/packages/theme-shared/src/public-api.ts +++ b/npm/ng-packs/packages/theme-shared/src/public-api.ts @@ -8,7 +8,7 @@ export { BOOTSTRAP } from './lib/constants/styles'; export * from './lib/constants/validation'; export * from './lib/directives'; export * from './lib/enums'; -export { ErrorHandler } from './lib/handlers'; +export * from './lib/handlers'; export * from './lib/models'; export * from './lib/providers'; export * from './lib/services'; diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs index 52a15ed4b2..26ad3a6a4d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs @@ -6,6 +6,7 @@ using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.MultiTenancy; using Volo.Abp.Account.Localization; using Volo.Abp.Identity.Blazor; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.SettingManagement.Blazor.Menus; using Volo.Abp.TenantManagement.Blazor.Navigation; using Volo.Abp.UI.Navigation; @@ -69,16 +70,11 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus { var l = context.GetLocalizer(); var accountStringLocalizer = context.GetLocalizer(); - var currentUser = context.ServiceProvider.GetRequiredService(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; - if (currentUser.IsAuthenticated) - { - context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank")); - context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000)); - } + context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); return Task.CompletedTask; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs index c42223526a..f8a0f7e509 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MyCompanyName.MyProjectName.Localization; using Volo.Abp.Account.Localization; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; @@ -50,20 +51,16 @@ namespace MyCompanyName.MyProjectName.Blazor.Menus private Task ConfigureUserMenuAsync(MenuConfigurationContext context) { var accountStringLocalizer = context.GetLocalizer(); - var currentUser = context.ServiceProvider.GetRequiredService(); var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; - if (currentUser.IsAuthenticated) - { - context.Menu.AddItem(new ApplicationMenuItem( - "Account.Manage", - accountStringLocalizer["ManageYourProfile"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", - icon: "fa fa-cog", - order: 1000, - null)); - } + context.Menu.AddItem(new ApplicationMenuItem( + "Account.Manage", + accountStringLocalizer["ManageYourProfile"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", + icon: "fa fa-cog", + order: 1000, + null).RequireAuthenticated()); return Task.CompletedTask; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs index 5bf2fc404f..90fb5595ed 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.MultiTenancy; using Volo.Abp.Account.Localization; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Identity.Web.Navigation; using Volo.Abp.SettingManagement.Web.Navigation; using Volo.Abp.TenantManagement.Web.Navigation; @@ -69,16 +70,11 @@ namespace MyCompanyName.MyProjectName.Web.Menus { var l = context.GetLocalizer(); var accountStringLocalizer = context.GetLocalizer(); - var currentUser = context.ServiceProvider.GetRequiredService(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; - if (currentUser.IsAuthenticated) - { - context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank")); - context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000)); - } + context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); return Task.CompletedTask; } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs index c1151363ab..ef27052921 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using MyCompanyName.MyProjectName.Localization; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; @@ -31,30 +32,25 @@ namespace MyCompanyName.MyProjectName private void AddLogoutItemToMenu(MenuConfigurationContext context) { - var currentUser = context.ServiceProvider.GetRequiredService(); var l = context.GetLocalizer(); - if (currentUser.IsAuthenticated) - { - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Manage", - l["ManageYourProfile"], - $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", - icon: "fa fa-cog", - order: int.MaxValue - 1001, - null, - "_blank") - ); - - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Logout", - l["Logout"], - "~/Account/Logout", - "fas fa-power-off", - order: int.MaxValue - 1000 - )); - } + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Manage", + l["ManageYourProfile"], + $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", + icon: "fa fa-cog", + order: int.MaxValue - 1001, + null, + "_blank" + ).RequireAuthenticated()); + + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Logout", + l["Logout"], + "~/Account/Logout", + "fas fa-power-off", + order: int.MaxValue - 1000 + ).RequireAuthenticated()); } } }