[REFACTOR] Refactored logging & added support for Microsoft.Extensions.Logging. Added test WebApi project
This commit is contained in:
@@ -18,21 +18,23 @@ public class BasedServerAuthenticationStateProvider : ServerAuthenticationStateP
|
||||
_config = configuration;
|
||||
_localStorage = localStorage;
|
||||
_securityService = securityService;
|
||||
_logger = LogService.RegisterLogger(typeof(BasedServerAuthenticationStateProvider));
|
||||
_logger = LogService.RegisterLogger<BasedServerAuthenticationStateProvider>();
|
||||
}
|
||||
|
||||
private BasedAuthConfiguration _config;
|
||||
private readonly ProtectedLocalStorage _localStorage;
|
||||
private readonly SecurityService _securityService;
|
||||
private ILogger _logger;
|
||||
private readonly ILogger _logger;
|
||||
private readonly AuthenticationState _anonState = new(new ClaimsPrincipal());
|
||||
|
||||
|
||||
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
{
|
||||
_logger.Debug("Getting authentication state...");
|
||||
var sessionIdResult = await _localStorage.GetAsync<string>(BasedAuthDefaults.StorageKey);
|
||||
if (!sessionIdResult.Success || sessionIdResult.Value == null)
|
||||
return _anonState;
|
||||
_logger.Debug("Found state [{State}], getting session from {Service}", sessionIdResult.Value, nameof(SecurityService));
|
||||
var stateResult = await _securityService.GetAuthenticationStateFromSessionAsync(sessionIdResult.Value);
|
||||
return stateResult is { Success: true, Value: not null } ? stateResult.Value : _anonState;
|
||||
}
|
||||
|
Reference in New Issue
Block a user