From 64642575d88e6f25d74935cf9fcc03a175585033 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 4 Apr 2024 15:34:33 +0800 Subject: [PATCH] Refresh app configuration after revoking token. --- .../WebAssemblyAuthenticationStateProvider.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyAuthenticationStateProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyAuthenticationStateProvider.cs index 37284a54a3..6a27b03ea7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyAuthenticationStateProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyAuthenticationStateProvider.cs @@ -16,6 +16,10 @@ using Microsoft.JSInterop; namespace Volo.Abp.AspNetCore.Components.WebAssembly; +/// +/// Blazor requests a new token each time it is initialized/refreshed. +/// This class is used to revoke a token that is no longer in use. +/// public class WebAssemblyAuthenticationStateProvider : RemoteAuthenticationService where TRemoteAuthenticationState : RemoteAuthenticationState where TProviderOptions : new() @@ -78,13 +82,6 @@ public class WebAssemblyAuthenticationStateProvider GetAuthenticationStateAsync() { - var state = await base.GetAuthenticationStateAsync(); - var applicationConfigurationDto = await WebAssemblyCachedApplicationConfigurationClient.GetAsync(); - if (state.User.Identity != null && state.User.Identity.IsAuthenticated && !applicationConfigurationDto.CurrentUser.IsAuthenticated) - { - await WebAssemblyCachedApplicationConfigurationClient.InitializeAsync(); - } - var accessToken = await FindAccessTokenAsync(); if (!accessToken.IsNullOrWhiteSpace()) { @@ -93,6 +90,13 @@ public class WebAssemblyAuthenticationStateProvider x.Value); var currentAccessToken = await FindAccessTokenAsync(); foreach (var accessToken in revokeAccessTokens) @@ -144,12 +149,18 @@ public class WebAssemblyAuthenticationStateProvider