|
|
|
@ -1,5 +1,7 @@ |
|
|
|
using System.Linq; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.ExtensionMethods.Collections.Generic; |
|
|
|
|
|
|
|
@ -9,13 +11,14 @@ namespace Volo.Abp.AspNetCore.MultiTenancy |
|
|
|
{ |
|
|
|
protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) |
|
|
|
{ |
|
|
|
//TODO: Get first one if provided multiple values and write a log
|
|
|
|
if (httpContext.Request.Headers.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
var tenantIdHeader = httpContext.Request.Headers[context.GetAspNetCoreMultiTenancyOptions().TenantIdKey]; |
|
|
|
var tenantIdKey = context.GetAspNetCoreMultiTenancyOptions().TenantIdKey; |
|
|
|
|
|
|
|
var tenantIdHeader = httpContext.Request.Headers[tenantIdKey]; |
|
|
|
if (tenantIdHeader == string.Empty || tenantIdHeader.Count < 1) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
@ -23,7 +26,9 @@ namespace Volo.Abp.AspNetCore.MultiTenancy |
|
|
|
|
|
|
|
if (tenantIdHeader.Count > 1) |
|
|
|
{ |
|
|
|
|
|
|
|
context.ServiceProvider.GetRequiredService<ILogger<HeaderTenantResolver>>().LogWarning( |
|
|
|
$"HTTP request includes more than one {tenantIdKey} header value. First one will be used. All of them: {tenantIdHeader.JoinAsString(", ")}" |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return tenantIdHeader.First(); |
|
|
|
|