Browse Source

Don't redirect when getting a `403` response.

pull/19954/head
maliming 2 years ago
parent
commit
c70f3946af
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 26
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ClientProxyExceptionEventHandler.cs

26
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ClientProxyExceptionEventHandler.cs

@ -26,31 +26,19 @@ public class ClientProxyExceptionEventHandler : ILocalEventHandler<ClientProxyEx
{ {
using (var scope = ServiceProvider.CreateScope()) using (var scope = ServiceProvider.CreateScope())
{ {
switch (eventData.StatusCode) if (eventData.StatusCode == 401)
{ {
case 401: var options = scope.ServiceProvider.GetRequiredService<IOptions<AbpAspNetCoreComponentsWebOptions>>();
if (!options.Value.IsBlazorWebApp)
{ {
var options = scope.ServiceProvider.GetRequiredService<IOptions<AbpAspNetCoreComponentsWebOptions>>(); var authenticationOptions = scope.ServiceProvider.GetRequiredService<IOptions<AbpAuthenticationOptions>>();
if (!options.Value.IsBlazorWebApp) var navigationManager = scope.ServiceProvider.GetRequiredService<NavigationManager>();
{ navigationManager.NavigateToLogout(authenticationOptions.Value.LogoutUrl, "/");
var authenticationOptions = scope.ServiceProvider.GetRequiredService<IOptions<AbpAuthenticationOptions>>();
var navigationManager = scope.ServiceProvider.GetRequiredService<NavigationManager>();
navigationManager.NavigateToLogout(authenticationOptions.Value.LogoutUrl, "/");
}
else
{
var jsRuntime = scope.ServiceProvider.GetRequiredService<IJSRuntime>();
await jsRuntime.InvokeVoidAsync("eval", "setTimeout(function(){location.assign('/')}, 2000)");
}
break;
} }
case 403: else
{ {
var jsRuntime = scope.ServiceProvider.GetRequiredService<IJSRuntime>(); var jsRuntime = scope.ServiceProvider.GetRequiredService<IJSRuntime>();
await jsRuntime.InvokeVoidAsync("eval", "setTimeout(function(){location.assign('/')}, 2000)"); await jsRuntime.InvokeVoidAsync("eval", "setTimeout(function(){location.assign('/')}, 2000)");
break;
} }
} }
} }

Loading…
Cancel
Save