Browse Source

Update DefaultAbpAuthorizationExceptionHandler.cs

pull/9940/head
maliming 5 years ago
parent
commit
9de6722b94
  1. 3
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs

3
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs

@ -13,11 +13,10 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
{ {
public virtual async Task<bool> HandleAsync(AbpAuthorizationException exception, HttpContext httpContext) public virtual async Task<bool> HandleAsync(AbpAuthorizationException exception, HttpContext httpContext)
{ {
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
var handlerOptions = httpContext.RequestServices.GetRequiredService<IOptions<AbpAuthorizationExceptionHandlerOptions>>().Value; var handlerOptions = httpContext.RequestServices.GetRequiredService<IOptions<AbpAuthorizationExceptionHandlerOptions>>().Value;
if (handlerOptions.UseAuthenticationScheme) if (handlerOptions.UseAuthenticationScheme)
{ {
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
var authenticationSchemeProvider = httpContext.RequestServices.GetRequiredService<IAuthenticationSchemeProvider>(); var authenticationSchemeProvider = httpContext.RequestServices.GetRequiredService<IAuthenticationSchemeProvider>();
var scheme = !handlerOptions.AuthenticationScheme.IsNullOrWhiteSpace() var scheme = !handlerOptions.AuthenticationScheme.IsNullOrWhiteSpace()
? await authenticationSchemeProvider.GetSchemeAsync(handlerOptions.AuthenticationScheme) ? await authenticationSchemeProvider.GetSchemeAsync(handlerOptions.AuthenticationScheme)

Loading…
Cancel
Save