From bb68bdcdc599f0cedc3269e1cca2095921ab11c5 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 13 May 2020 14:49:09 +0800 Subject: [PATCH 01/17] Move localization middleware above authentication middleware --- .../applications/AuthServer.Host/AuthServerHostModule.cs | 2 +- .../BackendAdminApp.Host/BackendAdminAppHostModule.cs | 2 +- .../PublicWebSite.Host/PublicWebSiteHostModule.cs | 2 +- .../BloggingService.Host/BloggingServiceHostModule.cs | 2 +- .../IdentityService.Host/IdentityServiceHostModule.cs | 2 +- .../ProductService.Host/ProductServiceHostModule.cs | 2 +- .../TenantManagementServiceHostModule.cs | 2 +- .../MyProjectNameHttpApiHostModule.cs | 2 +- .../MyProjectNameHttpApiHostModule.cs | 2 +- .../MyProjectNameIdentityServerModule.cs | 4 ++-- .../MyProjectNameWebModule.cs | 6 ++---- .../MyProjectNameWebModule.cs | 2 +- .../MyProjectNameWebTestModule.cs | 4 ++-- .../MyProjectNameHttpApiHostModule.cs | 2 +- .../MyProjectNameIdentityServerModule.cs | 2 +- .../MyProjectNameWebHostModule.cs | 4 ++-- .../MyProjectNameWebUnifiedModule.cs | 2 +- 17 files changed, 21 insertions(+), 23 deletions(-) diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs index 08b6689cea..095f3c5ddc 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs @@ -95,12 +95,12 @@ namespace AuthServer.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } app.UseIdentityServer(); - app.UseAbpRequestLocalization(); app.UseAuditing(); app.UseConfiguredEndpoints(); diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs index b0aba5af53..4414dc73ae 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -118,13 +118,13 @@ namespace BackendAdminApp.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index bc0bb83021..9ea7543228 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -96,13 +96,13 @@ namespace PublicWebSite.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseConfiguredEndpoints(); } } diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index 692d4c3d61..c546c57ae5 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -120,6 +120,7 @@ namespace BloggingService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -140,7 +141,6 @@ namespace BloggingService.Host { app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs index 982f4c09af..49c0bbd933 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs @@ -101,6 +101,7 @@ namespace IdentityService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); if (MsDemoConsts.IsMultiTenancyEnabled) { @@ -121,7 +122,6 @@ namespace IdentityService.Host await next(); }); - app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs index 44e23eeb78..9fb074fe76 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs @@ -104,6 +104,7 @@ namespace ProductService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -124,7 +125,6 @@ namespace ProductService.Host { app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs index f9a818234f..f068c2adf9 100644 --- a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs @@ -105,6 +105,7 @@ namespace TenantManagementService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -125,7 +126,6 @@ namespace TenantManagementService.Host { app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { 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 2526aec04d..f560ac7e0a 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 @@ -178,13 +178,13 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => 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 7a40f2eef5..06f52defb1 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 @@ -168,6 +168,7 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); @@ -178,7 +179,6 @@ namespace MyCompanyName.MyProjectName app.UseIdentityServer(); app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => 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 0a87b21a31..e3d6d5aa67 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -135,7 +135,7 @@ namespace MyCompanyName.MyProjectName }); }); } - + public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); @@ -154,6 +154,7 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { @@ -161,7 +162,6 @@ namespace MyCompanyName.MyProjectName } app.UseIdentityServer(); app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 0809a70cc4..86738e3e1b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -67,7 +67,7 @@ namespace MyCompanyName.MyProjectName.Web ); }); } - + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -225,6 +225,7 @@ namespace MyCompanyName.MyProjectName.Web app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) @@ -234,9 +235,6 @@ namespace MyCompanyName.MyProjectName.Web app.UseAuthorization(); - - app.UseAbpRequestLocalization(); - app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 8330951dfc..541a2c5e3a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -204,6 +204,7 @@ namespace MyCompanyName.MyProjectName.Web app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); @@ -213,7 +214,6 @@ namespace MyCompanyName.MyProjectName.Web } app.UseIdentityServer(); app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs index 20f7e793c2..edde134027 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs @@ -89,10 +89,10 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.Use(async (ctx, next) => { @@ -110,4 +110,4 @@ namespace MyCompanyName.MyProjectName app.UseConfiguredEndpoints(); } } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index e425512797..8de889e88e 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -165,13 +165,13 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index 9d0cb8397c..4bfd5f689a 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -186,6 +186,7 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); if (MultiTenancyConsts.IsEnabled) @@ -194,7 +195,6 @@ namespace MyCompanyName.MyProjectName } app.UseIdentityServer(); app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs index 385b840e75..6d16829e25 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs @@ -73,7 +73,7 @@ namespace MyCompanyName.MyProjectName ); }); } - + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -234,6 +234,7 @@ namespace MyCompanyName.MyProjectName app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) @@ -243,7 +244,6 @@ namespace MyCompanyName.MyProjectName app.UseAuthorization(); - app.UseAbpRequestLocalization(); app.UseSwagger(); app.UseSwaggerUI(options => diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs index 48b0667350..57b77e5f50 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs @@ -127,6 +127,7 @@ namespace MyCompanyName.MyProjectName app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); + app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseAuthorization(); if (MultiTenancyConsts.IsEnabled) @@ -140,7 +141,6 @@ namespace MyCompanyName.MyProjectName options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); }); - app.UseAbpRequestLocalization(); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); From 5b91c8954beae73903cb9a405ffe42d5374b86fa Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 13 May 2020 18:13:05 +0800 Subject: [PATCH 02/17] Check whether MethodInfo's DeclaringType has auditing disabled. --- .../Volo/Abp/Auditing/AuditingHelper.cs | 19 ++++++++++--------- .../Auditing/AuditingInterceptorRegistrar.cs | 10 +++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs index e53ba5b9a6..4c3ede4ca8 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs @@ -36,7 +36,7 @@ namespace Volo.Abp.Auditing IClock clock, IAuditingStore auditingStore, ILogger logger, - IServiceProvider serviceProvider, + IServiceProvider serviceProvider, ICorrelationIdProvider correlationIdProvider) { Options = options.Value; @@ -77,9 +77,10 @@ namespace Volo.Abp.Auditing var classType = methodInfo.DeclaringType; if (classType != null) { - if (AuditingInterceptorRegistrar.ShouldAuditTypeByDefault(classType)) + var shouldAudit = AuditingInterceptorRegistrar.ShouldAuditTypeByDefaultOrNull(classType); + if (shouldAudit != null) { - return true; + return shouldAudit.Value; } } @@ -123,7 +124,7 @@ namespace Volo.Abp.Auditing return defaultValue; } - + public virtual AuditLogInfo CreateAuditLogInfo() { var auditInfo = new AuditLogInfo @@ -147,8 +148,8 @@ namespace Volo.Abp.Auditing public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, - MethodInfo method, + Type type, + MethodInfo method, object[] arguments) { return CreateAuditLogAction(auditLog, type, method, CreateArgumentsDictionary(method, arguments)); @@ -156,8 +157,8 @@ namespace Volo.Abp.Auditing public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, - MethodInfo method, + Type type, + MethodInfo method, IDictionary arguments) { var actionInfo = new AuditLogActionInfo @@ -240,4 +241,4 @@ namespace Volo.Abp.Auditing return dictionary; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs index a407335f3d..54607a55ca 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs @@ -21,8 +21,8 @@ namespace Volo.Abp.Auditing { return false; } - - if (ShouldAuditTypeByDefault(type)) + + if (ShouldAuditTypeByDefaultOrNull(type) == true) { return true; } @@ -36,7 +36,7 @@ namespace Volo.Abp.Auditing } //TODO: Move to a better place - public static bool ShouldAuditTypeByDefault(Type type) + public static bool? ShouldAuditTypeByDefaultOrNull(Type type) { //TODO: In an inheritance chain, it would be better to check the attributes on the top class first. @@ -55,7 +55,7 @@ namespace Volo.Abp.Auditing return true; } - return false; + return null; } } -} \ No newline at end of file +} From e97f07b011b1786255ad31684579e87330b8f7ae Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 15 May 2020 12:21:29 +0800 Subject: [PATCH 03/17] Put UseAbpRequestLocalization just after the UseAuthentication --- .../BackendAdminApp.Host/BackendAdminAppHostModule.cs | 4 ++-- .../PublicWebSite.Host/PublicWebSiteHostModule.cs | 4 ++-- .../BloggingService.Host/BloggingServiceHostModule.cs | 4 ++-- .../IdentityService.Host/IdentityServiceHostModule.cs | 7 ++++--- .../ProductService.Host/ProductServiceHostModule.cs | 4 ++-- .../TenantManagementServiceHostModule.cs | 4 ++-- .../MyProjectNameHttpApiHostModule.cs | 4 ++-- .../MyProjectNameHttpApiHostModule.cs | 6 +++--- .../MyProjectNameIdentityServerModule.cs | 6 ++++-- .../MyProjectNameWebModule.cs | 4 ++-- .../MyProjectNameWebModule.cs | 4 ++-- .../MyProjectNameWebTestModule.cs | 6 +++--- .../MyProjectNameHttpApiHostModule.cs | 8 +++++--- .../MyProjectNameIdentityServerModule.cs | 8 +++++--- .../MyProjectNameWebHostModule.cs | 2 +- .../MyProjectNameWebUnifiedModule.cs | 3 ++- 16 files changed, 43 insertions(+), 35 deletions(-) diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs index 4414dc73ae..0976699f07 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; @@ -118,8 +118,8 @@ namespace BackendAdminApp.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index 9ea7543228..1b2c0de935 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; @@ -96,8 +96,8 @@ namespace PublicWebSite.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index c546c57ae5..97c351e93e 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -120,7 +120,6 @@ namespace BloggingService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -137,6 +136,7 @@ namespace BloggingService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); + app.UseAbpRequestLocalization(); //TODO: localization? if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs index 49c0bbd933..b950da980f 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Security.Claims; using Microsoft.AspNetCore.Builder; @@ -101,12 +101,14 @@ namespace IdentityService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); + app.UseAbpRequestLocalization(); //TODO: localization? + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + app.Use(async (ctx, next) => { var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService(); @@ -121,7 +123,6 @@ namespace IdentityService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); - app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs index 9fb074fe76..6bb74c1f2b 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Security.Claims; using Microsoft.AspNetCore.Builder; @@ -104,7 +104,6 @@ namespace ProductService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -121,6 +120,7 @@ namespace ProductService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); + app.UseAbpRequestLocalization(); //TODO: localization? if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); diff --git a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs index f068c2adf9..61c0d5105a 100644 --- a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Security.Claims; using Microsoft.AspNetCore.Builder; @@ -105,7 +105,6 @@ namespace TenantManagementService.Host app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); //TODO: localization? app.UseAuthentication(); app.Use(async (ctx, next) => @@ -122,6 +121,7 @@ namespace TenantManagementService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); + app.UseAbpRequestLocalization(); //TODO: localization? if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); 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 f560ac7e0a..5368ac81ed 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 @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using Microsoft.AspNetCore.Builder; @@ -178,8 +178,8 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); 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 06f52defb1..5b950c1d23 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 @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Net.Http; @@ -168,10 +168,10 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); - app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - + app.UseAbpRequestLocalization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); 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 e3d6d5aa67..6835c537dc 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using Localization.Resources.AbpUi; @@ -154,12 +154,14 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseIdentityServer(); app.UseAuthorization(); app.UseAuditing(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 86738e3e1b..12c20e9ffe 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Builder; @@ -225,8 +225,8 @@ namespace MyCompanyName.MyProjectName.Web app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 541a2c5e3a..1a578ac994 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using Localization.Resources.AbpUi; using Microsoft.AspNetCore; @@ -204,9 +204,9 @@ namespace MyCompanyName.MyProjectName.Web app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); + app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs index edde134027..28b5e3b55b 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using Localization.Resources.AbpUi; @@ -88,9 +88,9 @@ namespace MyCompanyName.MyProjectName }); app.UseVirtualFiles(); - app.UseRouting(); - app.UseAbpRequestLocalization(); + app.UseRouting(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); app.UseAuthorization(); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index 8de889e88e..845126a67b 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using IdentityModel; @@ -164,13 +164,15 @@ namespace MyCompanyName.MyProjectName app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); - app.UseAbpRequestLocalization(); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); + app.UseAbpRequestLocalization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(options => diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index 4bfd5f689a..11627c93b9 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; @@ -185,14 +185,16 @@ namespace MyCompanyName.MyProjectName app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); - app.UseAbpRequestLocalization(); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); + app.UseAbpRequestLocalization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs index 6d16829e25..cf306f5277 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs @@ -234,8 +234,8 @@ namespace MyCompanyName.MyProjectName app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs index 57b77e5f50..653738d8ac 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs @@ -127,9 +127,10 @@ namespace MyCompanyName.MyProjectName app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAbpRequestLocalization(); app.UseAuthentication(); + app.UseAbpRequestLocalization(); app.UseAuthorization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); From d0ef06e9287c84352d70de97353c5b5dfba52067 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 15 May 2020 14:44:27 +0800 Subject: [PATCH 04/17] Put UseAbpRequestLocalization after the UseMultiTenancy --- .../BackendAdminApp.Host/BackendAdminAppHostModule.cs | 4 +++- .../PublicWebSite.Host/PublicWebSiteHostModule.cs | 4 +++- .../BloggingService.Host/BloggingServiceHostModule.cs | 4 +++- .../IdentityService.Host/IdentityServiceHostModule.cs | 2 +- .../ProductService.Host/ProductServiceHostModule.cs | 4 +++- .../TenantManagementServiceHostModule.cs | 4 +++- .../MyProjectNameHttpApiHostModule.cs | 4 +++- .../MyProjectNameHttpApiHostModule.cs | 4 ++-- .../MyProjectNameIdentityServerModule.cs | 2 +- .../MyProjectNameWebModule.cs | 2 +- .../MyProjectNameWebModule.cs | 3 ++- .../MyProjectNameHttpApiHostModule.cs | 2 +- .../MyProjectNameIdentityServerModule.cs | 4 ++-- .../MyProjectNameWebHostModule.cs | 5 ++--- .../MyProjectNameWebUnifiedModule.cs | 7 ++++--- 15 files changed, 34 insertions(+), 21 deletions(-) diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs index 0976699f07..b351a33fb6 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -119,11 +119,13 @@ namespace BackendAdminApp.Host app.UseVirtualFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseAbpRequestLocalization(); + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(options => diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index 1b2c0de935..e1c0b8c215 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -97,11 +97,13 @@ namespace PublicWebSite.Host app.UseVirtualFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseAbpRequestLocalization(); + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseConfiguredEndpoints(); } diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index 97c351e93e..bc9209c72a 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -136,11 +136,13 @@ namespace BloggingService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); - app.UseAbpRequestLocalization(); //TODO: localization? + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs index b950da980f..457950cba4 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs @@ -102,7 +102,6 @@ namespace IdentityService.Host app.UseVirtualFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseAbpRequestLocalization(); //TODO: localization? if (MsDemoConsts.IsMultiTenancyEnabled) { @@ -123,6 +122,7 @@ namespace IdentityService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); + app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs index 6bb74c1f2b..4968ce75a4 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs @@ -120,11 +120,13 @@ namespace ProductService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); - app.UseAbpRequestLocalization(); //TODO: localization? + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs index 61c0d5105a..504713c047 100644 --- a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs @@ -121,11 +121,13 @@ namespace TenantManagementService.Host currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); await next(); }); - app.UseAbpRequestLocalization(); //TODO: localization? + if (MsDemoConsts.IsMultiTenancyEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); //TODO: localization? app.UseSwagger(); app.UseSwaggerUI(options => { 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 5368ac81ed..591b92ae44 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 @@ -179,11 +179,13 @@ namespace MyCompanyName.MyProjectName app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); - app.UseAbpRequestLocalization(); + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); 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 5b950c1d23..0cd3762047 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 @@ -169,14 +169,14 @@ namespace MyCompanyName.MyProjectName app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); - app.UseJwtTokenMiddleware(); - app.UseAbpRequestLocalization(); + app.UseJwtTokenMiddleware(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); 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 6835c537dc..8d23b73d0f 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -155,13 +155,13 @@ namespace MyCompanyName.MyProjectName app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); - app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); app.UseAuditing(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 12c20e9ffe..9e1930a260 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -226,13 +226,13 @@ namespace MyCompanyName.MyProjectName.Web app.UseVirtualFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 1a578ac994..8015f9ec45 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -206,12 +206,13 @@ namespace MyCompanyName.MyProjectName.Web app.UseRouting(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + + app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index 845126a67b..ab77d8050b 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -166,13 +166,13 @@ namespace MyCompanyName.MyProjectName app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); - app.UseAbpRequestLocalization(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(options => diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index 11627c93b9..41d31efc53 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -188,13 +188,13 @@ namespace MyCompanyName.MyProjectName app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - app.UseAbpRequestLocalization(); - + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs index cf306f5277..7381787bc3 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs @@ -234,17 +234,16 @@ namespace MyCompanyName.MyProjectName app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAuthentication(); - app.UseAbpRequestLocalization(); + app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); app.UseAuthorization(); - app.UseSwagger(); app.UseSwaggerUI(options => { diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs index 653738d8ac..246db32e3e 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs @@ -128,14 +128,15 @@ namespace MyCompanyName.MyProjectName app.UseVirtualFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseAbpRequestLocalization(); - app.UseAuthorization(); - + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); + app.UseAuthorization(); + app.UseSwagger(); app.UseSwaggerUI(options => { From 6ce85f2df7fdb2951b7cd1c9ed47119069eb3e44 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 15 May 2020 19:45:34 +0800 Subject: [PATCH 05/17] Fix modal open event bug --- .../bootstrap/modal-manager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index 21a8e0ce21..cc4122a373 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js @@ -95,8 +95,11 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f }); _$modal.on('shown.bs.modal', function () { - //focuses first element if it's a typeable input. + //focuses first element if it's a typeable input. var $firstVisibleInput = _$modal.find('input:not([type=hidden]):first'); + + _onOpenCallbacks.triggerAll(_publicApi); + if ($firstVisibleInput.hasClass("datepicker")) { return; //don't pop-up date pickers... } @@ -107,7 +110,6 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f } $firstVisibleInput.focus(); - _onOpenCallbacks.triggerAll(_publicApi); }); var modalClass = abp.modals[options.modalClass]; From 72b9b43e9130c098a085dbe563a231e8eb6e2f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 15 May 2020 23:29:42 +0300 Subject: [PATCH 06/17] Resolved #3963: Create a jstree package & bundle contributor. --- .../JsTree/JQueryFormScriptContributor.cs | 16 ++++++++++++ .../Mvc/UI/Packages/JsTree/JsTreeOptions.cs | 13 ++++++++++ .../Packages/JsTree/JsTreeStyleContributor.cs | 26 +++++++++++++++++++ npm/packs/jstree/abp.resourcemapping.js | 5 ++++ npm/packs/jstree/package.json | 12 +++++++++ 5 files changed, 72 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JQueryFormScriptContributor.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeStyleContributor.cs create mode 100644 npm/packs/jstree/abp.resourcemapping.js create mode 100644 npm/packs/jstree/package.json diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JQueryFormScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JQueryFormScriptContributor.cs new file mode 100644 index 0000000000..ca131c8aac --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JQueryFormScriptContributor.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JsTree +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class JsTreeScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/libs/jstree/jstree.min.js"); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeOptions.cs new file mode 100644 index 0000000000..d1dbe812bf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeOptions.cs @@ -0,0 +1,13 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JsTree +{ + public class JsTreeOptions + { + /// + /// Path of the style file for the JsTree library. + /// Setting to null ignores the style file. + /// + /// Default value: "/libs/jstree/themes/default/style.min.css". + /// + public string StylePath { get; set; } = "/libs/jstree/themes/default/style.min.css"; + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeStyleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeStyleContributor.cs new file mode 100644 index 0000000000..5944310c2c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JsTree/JsTreeStyleContributor.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JsTree +{ + public class JsTreeStyleContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + var options = context + .ServiceProvider + .GetRequiredService>() + .Value; + + if (options.StylePath.IsNullOrEmpty()) + { + return; + } + + context.Files.AddIfNotContains(options.StylePath); + } + } +} \ No newline at end of file diff --git a/npm/packs/jstree/abp.resourcemapping.js b/npm/packs/jstree/abp.resourcemapping.js new file mode 100644 index 0000000000..89b3e09d64 --- /dev/null +++ b/npm/packs/jstree/abp.resourcemapping.js @@ -0,0 +1,5 @@ +module.exports = { + mappings: { + "@node_modules/jstree/dist/**/*.*": "@libs/jstree/" + } +} \ No newline at end of file diff --git a/npm/packs/jstree/package.json b/npm/packs/jstree/package.json new file mode 100644 index 0000000000..feee4a81e2 --- /dev/null +++ b/npm/packs/jstree/package.json @@ -0,0 +1,12 @@ +{ + "version": "2.7.0", + "name": "@abp/jstree", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@abp/jquery": "^2.7.0", + "jstree": "^3.3.9" + }, + "gitHead": "0ea3895f3b0b489e3ea81fc88f8f0896b22b61bd" +} From 61c5186cd1b01b67032d30cb5dad36ee179d3375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 15 May 2020 23:58:13 +0300 Subject: [PATCH 07/17] Update badges --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 14b044f8b1..f89a8a86aa 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # ABP -[![Build Status](http://vjenkins.dynu.net:5480/job/abp/badge/icon)](http://ci.volosoft.com:5480/blue/organizations/jenkins/abp/activity) [![NuGet](https://img.shields.io/nuget/v/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) -[![NuGet Download](https://img.shields.io/nuget/dt/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) [![MyGet (with prereleases)](https://img.shields.io/myget/abp-nightly/vpre/Volo.Abp.svg?style=flat-square)](https://docs.abp.io/en/abp/latest/Nightly-Builds) +[![NuGet Download](https://img.shields.io/nuget/dt/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) This project is the next generation of the [ASP.NET Boilerplate](https://aspnetboilerplate.com/) web application framework. See [the announcement](https://blog.abp.io/abp/Abp-vNext-Announcement). From dc3360f92139df91f2ef4bf999840368d1ca903c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 00:03:54 +0300 Subject: [PATCH 08/17] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f89a8a86aa..7dd11a5362 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ABP +[![Build & Test](https://github.com/abpframework/abp/workflows/Main/badge.svg)](https://github.com/abpframework/abp/actions?query=workflow%3AMain) [![NuGet](https://img.shields.io/nuget/v/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) [![MyGet (with prereleases)](https://img.shields.io/myget/abp-nightly/vpre/Volo.Abp.svg?style=flat-square)](https://docs.abp.io/en/abp/latest/Nightly-Builds) [![NuGet Download](https://img.shields.io/nuget/dt/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) From 687fac36c83791681356f42c3b7db2205c7c12ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:04:29 +0300 Subject: [PATCH 09/17] add claims mapping middleware to the MyProjectNameHttpApiHostModule --- .../MyProjectNameHttpApiHostModule.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index e425512797..c5f72ff5b7 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Claims; using IdentityModel; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; @@ -170,6 +172,20 @@ namespace MyCompanyName.MyProjectName { app.UseMultiTenancy(); } + app.Use(async (ctx, next) => + { + var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService(); + var map = new Dictionary() + { + { "sub", AbpClaimTypes.UserId }, + { "role", AbpClaimTypes.Role }, + { "email", AbpClaimTypes.Email }, + //any other map + }; + var mapClaims = currentPrincipalAccessor.Principal.Claims.Where(p => map.Keys.Contains(p.Type)).ToList(); + currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer)))); + await next(); + }); app.UseAuthorization(); app.UseAbpRequestLocalization(); app.UseSwagger(); From 73bf96c86f898be10bf51ef626b23547462fe1e3 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Sat, 16 May 2020 02:10:41 +0300 Subject: [PATCH 10/17] Update en.json --- .../AbpIoLocalization/Admin/Localization/Resources/en.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json index 14a4eb345c..46cd1cb470 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json @@ -127,7 +127,7 @@ "Generate": "Generate", "MissingQuantityField": "The quantity field is required!", "MissingPriceField": "The Price field is required!", - "CodeUsageStatus": "Code Usage Status", + "CodeUsageStatus": "Status", "Country": "Country", "DeveloperCount": "Developer Count", "RequestCode": "Request Code", @@ -147,6 +147,7 @@ "EmailSent": "Email Sent", "SuccessfullySent": "Successfully Sent", "SuccessfullyDeleted": "Successfully Deleted", - "DiscountRequestDeletionWarningMessage": "Discount request will be deleted" + "DiscountRequestDeletionWarningMessage": "Discount request will be deleted" , + "BusinessType": "Business Type" } } \ No newline at end of file From 94bb704bb64ced26cf1ad4fa644578381427f408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:39:10 +0300 Subject: [PATCH 11/17] Delete MyProjectNamePage.cs --- .../Pages/MyProjectNamePage.cs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePage.cs diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePage.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePage.cs deleted file mode 100644 index 5fe044221d..0000000000 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.AspNetCore.Mvc.Localization; -using Microsoft.AspNetCore.Mvc.Razor.Internal; -using MyCompanyName.MyProjectName.Localization; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; - -namespace MyCompanyName.MyProjectName.Web.Pages -{ - /* Inherit your UI Pages from this class. To do that, add this line to your Pages (.cshtml files under the Page folder): - * @inherits MyCompanyName.MyProjectName.Web.Pages.MyProjectNamePage - */ - public abstract class MyProjectNamePage : AbpPage - { - [RazorInject] - public IHtmlLocalizer L { get; set; } - } -} From 146ec7309cdae1976f87c276b29cc3dab0b3fffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:39:36 +0300 Subject: [PATCH 12/17] Implement #3967 for AbpPageModel. --- .../Mvc/UI/RazorPages/AbpPageModel.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs index 8d62a4e188..f616a2f32d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Alerts; using Volo.Abp.AspNetCore.Mvc.Validation; using Volo.Abp.Guids; +using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; using Volo.Abp.ObjectMapping; using Volo.Abp.Settings; @@ -90,17 +91,29 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages { if (_localizer == null) { - if (LocalizationResourceType == null) - { - throw new AbpException($"{nameof(LocalizationResourceType)} should be set before using the {nameof(L)} object!"); - } - - _localizer = StringLocalizerFactory.Create(LocalizationResourceType); + _localizer = CreateLocalizer(); } return _localizer; } } + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResourceType != null) + { + return StringLocalizerFactory.Create(LocalizationResourceType); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResourceType)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } + private IStringLocalizer _localizer; protected Type LocalizationResourceType { get; set; } From c122fdfad6d8fb8f670db060eaaf6ff55473fb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:48:29 +0300 Subject: [PATCH 13/17] Resolved #3967: Fallback to the default localization resource for base classes with the L property --- .../Mvc/UI/RazorPages/AbpPageModel.cs | 32 +++++----- .../Volo/Abp/AspNetCore/Mvc/AbpController.cs | 29 +++++++++- .../Volo/Abp/AspNetCore/SignalR/AbpHub.cs | 58 ++++++++++++++++++- .../Services/ApplicationService.cs | 29 +++++++++- 4 files changed, 128 insertions(+), 20 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs index f616a2f32d..db7b9041b7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs @@ -98,22 +98,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages } } - protected virtual IStringLocalizer CreateLocalizer() - { - if (LocalizationResourceType != null) - { - return StringLocalizerFactory.Create(LocalizationResourceType); - } - - var localizer = StringLocalizerFactory.CreateDefaultOrNull(); - if (localizer == null) - { - throw new AbpException($"Set {nameof(LocalizationResourceType)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); - } - - return localizer; - } - private IStringLocalizer _localizer; protected Type LocalizationResourceType { get; set; } @@ -165,5 +149,21 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages TempData = TempData }; } + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResourceType != null) + { + return StringLocalizerFactory.Create(LocalizationResourceType); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResourceType)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs index 2a3a25373e..52f01e0b2c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs @@ -101,7 +101,18 @@ namespace Volo.Abp.AspNetCore.Mvc public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); private IStringLocalizerFactory _stringLocalizerFactory; - public IStringLocalizer L => _localizer ?? (_localizer = StringLocalizerFactory.Create(LocalizationResource)); + public IStringLocalizer L + { + get + { + if (_localizer == null) + { + _localizer = CreateLocalizer(); + } + + return _localizer; + } + } private IStringLocalizer _localizer; protected Type LocalizationResource @@ -121,5 +132,21 @@ namespace Volo.Abp.AspNetCore.Mvc { ModelValidator?.Validate(ModelState); } + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResource != null) + { + return StringLocalizerFactory.Create(LocalizationResource); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs index a1dc1437ea..0a58adf098 100644 --- a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs +++ b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs @@ -57,7 +57,18 @@ namespace Volo.Abp.AspNetCore.SignalR public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); private IStringLocalizerFactory _stringLocalizerFactory; - public IStringLocalizer L => _localizer ?? (_localizer = StringLocalizerFactory.Create(LocalizationResource)); + public IStringLocalizer L + { + get + { + if (_localizer == null) + { + _localizer = CreateLocalizer(); + } + + return _localizer; + } + } private IStringLocalizer _localizer; protected Type LocalizationResource @@ -70,6 +81,22 @@ namespace Volo.Abp.AspNetCore.SignalR } } private Type _localizationResource = typeof(DefaultResource); + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResource != null) + { + return StringLocalizerFactory.Create(LocalizationResource); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } } public abstract class AbpHub : Hub @@ -118,7 +145,18 @@ namespace Volo.Abp.AspNetCore.SignalR public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); private IStringLocalizerFactory _stringLocalizerFactory; - public IStringLocalizer L => _localizer ?? (_localizer = StringLocalizerFactory.Create(LocalizationResource)); + public IStringLocalizer L + { + get + { + if (_localizer == null) + { + _localizer = CreateLocalizer(); + } + + return _localizer; + } + } private IStringLocalizer _localizer; protected Type LocalizationResource @@ -131,5 +169,21 @@ namespace Volo.Abp.AspNetCore.SignalR } } private Type _localizationResource = typeof(DefaultResource); + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResource != null) + { + return StringLocalizerFactory.Create(LocalizationResource); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } } } diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs index 32c90677b8..552aae426d 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs @@ -109,7 +109,18 @@ namespace Volo.Abp.Application.Services public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); private IStringLocalizerFactory _stringLocalizerFactory; - public IStringLocalizer L => _localizer ?? (_localizer = StringLocalizerFactory.Create(LocalizationResource)); + public IStringLocalizer L + { + get + { + if (_localizer == null) + { + _localizer = CreateLocalizer(); + } + + return _localizer; + } + } private IStringLocalizer _localizer; protected Type LocalizationResource @@ -147,5 +158,21 @@ namespace Volo.Abp.Application.Services await AuthorizationService.CheckAsync(policyName); } + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResource != null) + { + return StringLocalizerFactory.Create(LocalizationResource); + } + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) + { + throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); + } + + return localizer; + } } } \ No newline at end of file From 94a5bffebefb4e04ba45ee8d111aaa92d6bc50b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:51:35 +0300 Subject: [PATCH 14/17] Fix Index.cshtml of the app template --- .../src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml index e3df314288..a2fc159766 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml @@ -1,6 +1,10 @@ @page -@inherits MyCompanyName.MyProjectName.Web.Pages.MyProjectNamePage +@using Microsoft.AspNetCore.Mvc.Localization +@using MyCompanyName.MyProjectName.Localization +@using Volo.Abp.Users @model MyCompanyName.MyProjectName.Web.Pages.IndexModel +@inject IHtmlLocalizer +@inject ICurrentUser CurrentUser @section styles { From 8ad6a3a124fa55e61a3171e5c4ab8b9c74b62d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 16 May 2020 02:51:54 +0300 Subject: [PATCH 15/17] Update Index.cshtml --- .../src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml index a2fc159766..7329ce019b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml @@ -3,7 +3,7 @@ @using MyCompanyName.MyProjectName.Localization @using Volo.Abp.Users @model MyCompanyName.MyProjectName.Web.Pages.IndexModel -@inject IHtmlLocalizer +@inject IHtmlLocalizer L @inject ICurrentUser CurrentUser @section styles { From 67a230d3a0e4f92ab65ffee6ebb8c5cbc307e7eb Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Sat, 16 May 2020 14:02:47 +0800 Subject: [PATCH 16/17] Rename main.yml to build-and-test.yml Resolve #3965 --- .github/workflows/{main.yml => build-and-test.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{main.yml => build-and-test.yml} (96%) diff --git a/.github/workflows/main.yml b/.github/workflows/build-and-test.yml similarity index 96% rename from .github/workflows/main.yml rename to .github/workflows/build-and-test.yml index e33a07a197..395f88351a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -name: "Main" +name: "build and test" on: pull_request: paths: From 37490be9a0fb16a859ba77d80d926096f65dfeca Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Sat, 16 May 2020 14:12:04 +0800 Subject: [PATCH 17/17] Update README.md https://github.com/abpframework/abp/issues/3965 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dd11a5362..72a47ddc4b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ABP -[![Build & Test](https://github.com/abpframework/abp/workflows/Main/badge.svg)](https://github.com/abpframework/abp/actions?query=workflow%3AMain) +![build and test](https://github.com/abpframework/abp/workflows/build%20and%20test/badge.svg) [![NuGet](https://img.shields.io/nuget/v/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) [![MyGet (with prereleases)](https://img.shields.io/myget/abp-nightly/vpre/Volo.Abp.svg?style=flat-square)](https://docs.abp.io/en/abp/latest/Nightly-Builds) [![NuGet Download](https://img.shields.io/nuget/dt/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core)