Browse Source
Add bool return value to `MultiTenancyMiddlewareErrorPageBuilder` decide to continue the pipeline.
pull/13245/head
maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
3 changed files with
11 additions and
4 deletions
-
docs/en/Multi-Tenancy.md
-
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs
-
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
|
|
|
@ -44,6 +44,9 @@ Configure<AbpMultiTenancyOptions>(options => |
|
|
|
options.MultiTenancyMiddlewareErrorPageBuilder = async (context, exception) => |
|
|
|
{ |
|
|
|
// Handle the exception. |
|
|
|
|
|
|
|
//return true to stop the pipeline false to continue. |
|
|
|
return true; |
|
|
|
}; |
|
|
|
}); |
|
|
|
``` |
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ public class AbpAspNetCoreMultiTenancyOptions |
|
|
|
/// </summary>
|
|
|
|
public string TenantKey { get; set; } |
|
|
|
|
|
|
|
public Func<HttpContext, Exception, Task> MultiTenancyMiddlewareErrorPageBuilder { get; set; } |
|
|
|
public Func<HttpContext, Exception, Task<bool>> MultiTenancyMiddlewareErrorPageBuilder { get; set; } |
|
|
|
|
|
|
|
public AbpAspNetCoreMultiTenancyOptions() |
|
|
|
{ |
|
|
|
@ -44,6 +44,8 @@ public class AbpAspNetCoreMultiTenancyOptions |
|
|
|
|
|
|
|
// Note the 500 spaces are to work around an IE 'feature'
|
|
|
|
await context.Response.WriteAsync(new string(' ', 500)); |
|
|
|
|
|
|
|
return true; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -34,15 +34,17 @@ public class MultiTenancyMiddleware : IMiddleware, ITransientDependency |
|
|
|
|
|
|
|
public async Task InvokeAsync(HttpContext context, RequestDelegate next) |
|
|
|
{ |
|
|
|
TenantConfiguration tenant; |
|
|
|
TenantConfiguration tenant = null; |
|
|
|
try |
|
|
|
{ |
|
|
|
tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult: true); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e); |
|
|
|
return; |
|
|
|
if (await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (tenant?.Id != _currentTenant.Id) |
|
|
|
|