From dbabaaadba742a2720364119a1fa5078c3abda9b Mon Sep 17 00:00:00 2001 From: hello Date: Thu, 4 Jul 2024 07:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=A7=9F=E6=88=B7=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MultiTenancySample.ServiceDefaults/TenantIdProvider.cs | 5 +++++ samples/MultiTenancySample/global.json | 6 ------ .../BrandApiIntegrationTest.cs | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 samples/MultiTenancySample/global.json diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs index c4990d1..eda8382 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs @@ -10,6 +10,11 @@ namespace MultiTenancySample.ServiceDefaults const string tenantKey = "tenant"; + if(httpContext.User.FindAll(tenantKey).Any()) + { + return httpContext.User.FindFirst(tenantKey)?.Value; + } + if (httpContext.Request.Headers.TryGetValue(tenantKey, out var headerValues)) { return headerValues.First(); diff --git a/samples/MultiTenancySample/global.json b/samples/MultiTenancySample/global.json deleted file mode 100644 index 40975d5..0000000 --- a/samples/MultiTenancySample/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "8.0.204", - "rollForward": "latestFeature" - } -} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs b/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs index 5e53675..794f8db 100644 --- a/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs +++ b/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs @@ -21,7 +21,6 @@ namespace HelloShop.ProductService.FunctionalTests // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } [Fact]