Fix authentication state revalidation code in project template
This commit is contained in:
parent
b472b0afaf
commit
5c81754bad
|
|
@ -64,7 +64,7 @@ namespace RazorComponentsWeb_CSharp.Areas.Identity
|
|||
{
|
||||
// Force sign-out. Also stop the revalidation loop, because the user can
|
||||
// only sign back in by starting a new connection.
|
||||
var anonymousUser = new ClaimsPrincipal();
|
||||
var anonymousUser = new ClaimsPrincipal(new ClaimsIdentity());
|
||||
_currentAuthenticationStateTask = Task.FromResult(new AuthenticationState(anonymousUser));
|
||||
NotifyAuthenticationStateChanged(_currentAuthenticationStateTask);
|
||||
_loopCancellationTokenSource.Cancel();
|
||||
|
|
|
|||
|
|
@ -67,8 +67,6 @@ namespace RazorComponentsWeb_CSharp
|
|||
#endif
|
||||
services.AddDefaultIdentity<IdentityUser>()
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
|
||||
services.AddScoped<AuthenticationStateProvider, RevalidatingAuthenticationStateProvider<IdentityUser>>();
|
||||
#elif (OrganizationalAuth)
|
||||
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
|
||||
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
|
||||
|
|
@ -127,6 +125,9 @@ namespace RazorComponentsWeb_CSharp
|
|||
#endif
|
||||
services.AddRazorPages();
|
||||
services.AddServerSideBlazor();
|
||||
#if (IndividualLocalAuth)
|
||||
services.AddScoped<AuthenticationStateProvider, RevalidatingAuthenticationStateProvider<IdentityUser>>();
|
||||
#endif
|
||||
services.AddSingleton<WeatherForecastService>();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue