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
|
// Force sign-out. Also stop the revalidation loop, because the user can
|
||||||
// only sign back in by starting a new connection.
|
// 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));
|
_currentAuthenticationStateTask = Task.FromResult(new AuthenticationState(anonymousUser));
|
||||||
NotifyAuthenticationStateChanged(_currentAuthenticationStateTask);
|
NotifyAuthenticationStateChanged(_currentAuthenticationStateTask);
|
||||||
_loopCancellationTokenSource.Cancel();
|
_loopCancellationTokenSource.Cancel();
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,6 @@ namespace RazorComponentsWeb_CSharp
|
||||||
#endif
|
#endif
|
||||||
services.AddDefaultIdentity<IdentityUser>()
|
services.AddDefaultIdentity<IdentityUser>()
|
||||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||||
|
|
||||||
services.AddScoped<AuthenticationStateProvider, RevalidatingAuthenticationStateProvider<IdentityUser>>();
|
|
||||||
#elif (OrganizationalAuth)
|
#elif (OrganizationalAuth)
|
||||||
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
|
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
|
||||||
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
|
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
|
||||||
|
|
@ -127,6 +125,9 @@ namespace RazorComponentsWeb_CSharp
|
||||||
#endif
|
#endif
|
||||||
services.AddRazorPages();
|
services.AddRazorPages();
|
||||||
services.AddServerSideBlazor();
|
services.AddServerSideBlazor();
|
||||||
|
#if (IndividualLocalAuth)
|
||||||
|
services.AddScoped<AuthenticationStateProvider, RevalidatingAuthenticationStateProvider<IdentityUser>>();
|
||||||
|
#endif
|
||||||
services.AddSingleton<WeatherForecastService>();
|
services.AddSingleton<WeatherForecastService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue