From 5e3d2d21dd6d9601d9dfbd9f4bb0ffeabb88ffa9 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 6 Aug 2019 17:20:25 +0800 Subject: [PATCH 1/5] Add the AbpExposeHeaders extension method. --- .../Cors/AbpCorsPolicyBuilderExtensions.cs | 12 ++++++++++++ .../Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj | 1 + 2 files changed, 13 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs new file mode 100644 index 0000000000..fbff6f5fd2 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Cors.Infrastructure; + +namespace Microsoft.AspNetCore.Cors +{ + public static class AbpCorsPolicyBuilderExtensions + { + public static CorsPolicyBuilder WithAbpExposeHeaders(this CorsPolicyBuilder corsPolicyBuilder) + { + return corsPolicyBuilder.WithExposedHeaders("_AbpErrorFormat"); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj index fb85cbb3ec..2584654ce8 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj +++ b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj @@ -32,6 +32,7 @@ + From 6b7dcab12e7eafe30b15b3725138c224ecdae6e9 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 6 Aug 2019 17:45:37 +0800 Subject: [PATCH 2/5] Rename the method and apply it to the template project. --- .../Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs | 2 +- .../MyProjectNameHttpApiHostModule.cs | 2 ++ .../MyProjectNameHttpApiHostModule.cs | 2 ++ .../MyProjectNameIdentityServerModule.cs | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs index fbff6f5fd2..e466b1e058 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs @@ -4,7 +4,7 @@ namespace Microsoft.AspNetCore.Cors { public static class AbpCorsPolicyBuilderExtensions { - public static CorsPolicyBuilder WithAbpExposeHeaders(this CorsPolicyBuilder corsPolicyBuilder) + public static CorsPolicyBuilder WithAbpExposedHeaders(this CorsPolicyBuilder corsPolicyBuilder) { return corsPolicyBuilder.WithExposedHeaders("_AbpErrorFormat"); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index cdf4e08d92..feef7b52bd 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -134,6 +135,7 @@ namespace MyCompanyName.MyProjectName .Select(o => o.RemovePostFix("/")) .ToArray() ) + .WithAbpExposedHeaders() .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs index 003edae216..979a3dd417 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Net.Http; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -133,6 +134,7 @@ namespace MyCompanyName.MyProjectName .Select(o => o.RemovePostFix("/")) .ToArray() ) + .WithAbpExposedHeaders() .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index 959bea22bb..a3b3bf27aa 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; @@ -114,6 +115,7 @@ namespace MyCompanyName.MyProjectName .Select(o => o.RemovePostFix("/")) .ToArray() ) + .WithAbpExposedHeaders() .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() From aabdd72dd403cc9ec7612d92fa898a4068b54ced Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 6 Aug 2019 17:51:24 +0800 Subject: [PATCH 3/5] Update CLI.md --- docs/en/CLI.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/CLI.md b/docs/en/CLI.md index e0f4d29fb2..af7159bc22 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -105,6 +105,7 @@ abp add-module Volo.Blogging * `--solution` or `-s`: Specifies the solution (.sln) file path. If not specified, CLI tries to find a .sln file in the current directory. * `--skip-db-migrations`: For EF Core database provider, it automatically adds a new code first migration (`Add-Migration`) and updates the database (`Update-Database`) if necessary. Specify this option to skip this operation. +* `-sp` or `--startup-project`: Relative path to the project folder of the startup project. Default value is the current folder. ### update From 10b89c67c180f136c314800589284dac06c9903f Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 6 Aug 2019 13:53:06 +0300 Subject: [PATCH 4/5] identityroleappservice imrovements --- .../Volo/Abp/Identity/GetIdentityRolesInput.cs | 4 ++-- .../Abp/Identity/IIdentityRoleAppService.cs | 14 +++++++++++--- .../Volo/Abp/Identity/IdentityRoleAppService.cs | 15 ++------------- .../Volo/Abp/Identity/IdentityRoleController.cs | 17 +++++------------ .../Pages/Identity/Roles/index.js | 3 +++ .../Pages/Identity/Users/CreateModal.cshtml.cs | 4 ++-- .../Pages/Identity/Users/EditModal.cshtml.cs | 4 ++-- .../Identity/IdentityRoleAppService_Tests.cs | 3 +-- 8 files changed, 28 insertions(+), 36 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs index c5db3405a8..96c854c5b8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs @@ -2,8 +2,8 @@ namespace Volo.Abp.Identity { - public class GetIdentityRolesInput : PagedAndSortedResultRequestDto + public class GetIdentityRolesInput { - public string Filter { get; set; } + } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs index 0d8f19f796..3fec60599d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs @@ -1,13 +1,21 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; namespace Volo.Abp.Identity { - public interface IIdentityRoleAppService : ICrudAppService + public interface IIdentityRoleAppService : IApplicationService { - //TODO: remove after a better design - Task> GetAllListAsync(); + Task> GetListAsync(); + + Task CreateAsync(IdentityRoleCreateDto input); + + Task GetAsync(Guid id); + + Task UpdateAsync(Guid id, IdentityRoleUpdateDto input); + + Task DeleteAsync(Guid id); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index c91fc5ce1b..939d9739d2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -31,22 +31,11 @@ namespace Volo.Abp.Identity ); } - public async Task> GetListAsync(GetIdentityRolesInput input) //TODO: Remove this method since it's not used + public async Task> GetListAsync() { - var count = (int) await _roleRepository.GetCountAsync(); var list = await _roleRepository.GetListAsync(); - return new PagedResultDto( - count, - ObjectMapper.Map, List>(list) - ); - } - - public async Task> GetAllListAsync() //TODO: Rename to GetList (however it's not possible because of the design of the IAsyncCrudAppService) - { - var list = await _roleRepository.GetListAsync(); - - return ObjectMapper.Map, List>(list); + return new ListResultDto(ObjectMapper.Map, List>(list)); } [Authorize(IdentityPermissions.Roles.Create)] diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs index ca11d75f48..0a45c00f50 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs @@ -21,16 +21,16 @@ namespace Volo.Abp.Identity } [HttpGet] - [Route("{id}")] - public virtual Task GetAsync(Guid id) + public virtual Task> GetListAsync() { - return _roleAppService.GetAsync(id); + return _roleAppService.GetListAsync(); } [HttpGet] - public virtual Task> GetListAsync(GetIdentityRolesInput input) + [Route("{id}")] + public virtual Task GetAsync(Guid id) { - return _roleAppService.GetListAsync(input); + return _roleAppService.GetAsync(id); } [HttpPost] @@ -52,12 +52,5 @@ namespace Volo.Abp.Identity { return _roleAppService.DeleteAsync(id); } - - [HttpGet] - [Route("all")] - public virtual Task> GetAllListAsync() - { - return _roleAppService.GetAllListAsync(); - } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js index 385b53f257..cde584cf20 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js @@ -14,6 +14,9 @@ var _dataTable = _$table.DataTable(abp.libs.datatables.normalizeConfiguration({ order: [[1, "asc"]], + searching:false, + paging:false, + info:false, ajax: abp.libs.datatables.createAjax(_identityRoleAppService.getList), columnDefs: [ { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index ce7a5a0507..4d36736501 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -28,9 +28,9 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users { UserInfo = new UserInfoViewModel(); - var roleDtoList = await _identityRoleAppService.GetAllListAsync(); + var roleDtoList = await _identityRoleAppService.GetListAsync(); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList); + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList.Items); foreach (var role in Roles) { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 0655331fb9..1b166b881f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -30,8 +30,8 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users { UserInfo = ObjectMapper.Map(await _identityUserAppService.GetAsync(id)); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>( - await _identityRoleAppService.GetAllListAsync() + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>( + (await _identityRoleAppService.GetListAsync()).Items ); var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs index d20294da5c..03e872271f 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs @@ -38,11 +38,10 @@ namespace Volo.Abp.Identity { //Act - var result = await _roleAppService.GetListAsync(new GetIdentityRolesInput()); + var result = await _roleAppService.GetListAsync(); //Assert - result.TotalCount.ShouldBeGreaterThan(0); result.Items.Count.ShouldBeGreaterThan(0); } From 344c7e139d6debcdb7793a24aebecc4117985295 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 6 Aug 2019 14:01:36 +0300 Subject: [PATCH 5/5] removed unused codes --- .../Volo/Abp/Identity/GetIdentityRolesInput.cs | 9 --------- .../Volo/Abp/Identity/IdentityRoleController.cs | 1 - 2 files changed, 10 deletions(-) delete mode 100644 modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs deleted file mode 100644 index 96c854c5b8..0000000000 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Volo.Abp.Application.Dtos; - -namespace Volo.Abp.Identity -{ - public class GetIdentityRolesInput - { - - } -} diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs index 0a45c00f50..35ec928f5c 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Dtos;