Browse Source

Update AbpAspNetCoreComponentsWebAssemblyModule.cs

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

9
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Volo.Abp.AspNetCore.Components.Web;
using Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
@ -53,8 +54,7 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule
public override void PostConfigureServices(ServiceConfigurationContext context)
{
var msAuthenticationStateProvider = context.Services.FirstOrDefault(x => x.ServiceType == typeof(AuthenticationStateProvider));
if (msAuthenticationStateProvider != null &&
msAuthenticationStateProvider.ImplementationType != null &&
if (msAuthenticationStateProvider is {ImplementationType: not null} &&
msAuthenticationStateProvider.ImplementationType.IsGenericType &&
msAuthenticationStateProvider.ImplementationType.GetGenericTypeDefinition() == typeof(RemoteAuthenticationService<,,>))
{
@ -63,10 +63,7 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule
msAuthenticationStateProvider.ImplementationType.GenericTypeArguments[1],
msAuthenticationStateProvider.ImplementationType.GenericTypeArguments[2]);
context.Services.AddScoped(webAssemblyAuthenticationStateProviderType, webAssemblyAuthenticationStateProviderType);
context.Services.Remove(msAuthenticationStateProvider);
context.Services.AddScoped(typeof(AuthenticationStateProvider), sp => sp.GetRequiredService(webAssemblyAuthenticationStateProviderType));
context.Services.Replace(ServiceDescriptor.Scoped(typeof(AuthenticationStateProvider), webAssemblyAuthenticationStateProviderType));
}
}

Loading…
Cancel
Save