nettoyage des warning, ajout de localization
All checks were successful
Generation data pour merge sur master / reviewProcess (pull_request) Successful in 1m21s
Generation data pour merge sur master / generateData (pull_request) Successful in 1m31s
Generation data pour merge sur master / generateData (push) Has been skipped
Generation data pour merge sur master / reviewProcess (push) Successful in 1m16s

This commit was merged in pull request #22.
This commit is contained in:
2024-09-09 23:16:34 +02:00
parent cd4788b2b0
commit 0cde51e01c
21 changed files with 376 additions and 122 deletions

View File

@@ -7,6 +7,8 @@ using LudikZoneBlazor.Data;
namespace LudikZoneBlazor.Components.Account;
#pragma warning disable CA1812 // Elle est instanciée en Injection de dependance
// This is a server-side AuthenticationStateProvider that revalidates the security stamp for the connected user
// every 30 minutes an interactive circuit is connected.
internal sealed class IdentityRevalidatingAuthenticationStateProvider(
@@ -21,14 +23,14 @@ internal sealed class IdentityRevalidatingAuthenticationStateProvider(
AuthenticationState authenticationState, CancellationToken cancellationToken)
{
// Get the user manager from a new scope to ensure it fetches fresh data
await using var scope = scopeFactory.CreateAsyncScope();
using AsyncServiceScope scope = scopeFactory.CreateAsyncScope();
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
return await ValidateSecurityStampAsync(userManager, authenticationState.User);
return await ValidateSecurityStampAsync(userManager, authenticationState.User).ConfigureAwait(false);
}
private async Task<bool> ValidateSecurityStampAsync(UserManager<ApplicationUser> userManager, ClaimsPrincipal principal)
{
var user = await userManager.GetUserAsync(principal);
var user = await userManager.GetUserAsync(principal).ConfigureAwait(false);
if (user is null)
{
return false;
@@ -40,8 +42,10 @@ internal sealed class IdentityRevalidatingAuthenticationStateProvider(
else
{
var principalStamp = principal.FindFirstValue(options.Value.ClaimsIdentity.SecurityStampClaimType);
var userStamp = await userManager.GetSecurityStampAsync(user);
var userStamp = await userManager.GetSecurityStampAsync(user).ConfigureAwait(false);
return principalStamp == userStamp;
}
}
}
#pragma warning restore CA1812