@@ -11,13 +11,10 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
1111
1212internal sealed class DeserializedAuthenticationStateProvider : AuthenticationStateProvider
1313{
14- // Do not change. This must match all versions of the server-side AuthenticationStateSerializer.PersistenceKey.
15- private const string PersistenceKey = $ "__internal__{ nameof ( AuthenticationState ) } ";
16-
1714 private static readonly Task < AuthenticationState > _defaultUnauthenticatedTask =
1815 Task . FromResult ( new AuthenticationState ( new ClaimsPrincipal ( new ClaimsIdentity ( ) ) ) ) ;
1916
20- private Task < AuthenticationState > _authenticationStateTask = _defaultUnauthenticatedTask ;
17+ private readonly Task < AuthenticationState > _authenticationStateTask ;
2118
2219 [ SupplyParameterFromPersistentComponentState ]
2320 private AuthenticationStateData ? AuthStateData { get ; set ; }
@@ -29,20 +26,11 @@ internal sealed class DeserializedAuthenticationStateProvider : AuthenticationSt
2926 [ DynamicDependency ( JsonSerialized , typeof ( AuthenticationStateData ) ) ]
3027 [ DynamicDependency ( JsonSerialized , typeof ( IList < ClaimData > ) ) ]
3128 [ DynamicDependency ( JsonSerialized , typeof ( ClaimData ) ) ]
32- public DeserializedAuthenticationStateProvider ( PersistentComponentState state , IOptions < AuthenticationStateDeserializationOptions > options )
29+ public DeserializedAuthenticationStateProvider ( IOptions < AuthenticationStateDeserializationOptions > options )
3330 {
34- // For backwards compatibility, try to read from the direct state first
35- if ( AuthStateData is null &&
36- state . TryTakeFromJson < AuthenticationStateData ? > ( PersistenceKey , out var authenticationStateData ) &&
37- authenticationStateData is not null )
38- {
39- AuthStateData = authenticationStateData ;
40- }
41-
42- if ( AuthStateData is not null )
43- {
44- _authenticationStateTask = options . Value . DeserializationCallback ( AuthStateData ) ;
45- }
31+ _authenticationStateTask = AuthStateData is not null
32+ ? options . Value . DeserializationCallback ( AuthStateData )
33+ : _defaultUnauthenticatedTask ;
4634 }
4735
4836 public override Task < AuthenticationState > GetAuthenticationStateAsync ( ) => _authenticationStateTask ;
0 commit comments