public async Task AssertClaimAsync(string queryParameter, string claimType) { _logger.LogInformation($"AssertClaim called with parameters: <{queryParameter}>, <{claimType}>"); var extractedQueryParameter = UrlQueryParameterExtractor.ExtractQueryParameterFromManager(_navigationManager, queryParameter); if (string.IsNullOrWhiteSpace(extractedQueryParameter)) { _logger.LogInformation($"RETURN: extractedQueryParameter is null, empty or whitespace: <{extractedQueryParameter}>"); return; } _logger.LogInformation($"extractedQueryParameter is <{extractedQueryParameter}>"); var authenticationState = await _authenticationStateProvider.GetAuthenticationStateAsync(); var user = authenticationState.User; if (!user.Identity.IsAuthenticated) { _logger.LogInformation($"RETURN: user is not authenticated"); return; } _logger.LogInformation($"user is not null and authenticated"); var optionClaim = user.Claims.FirstOrNone(x => x.Type == claimType); _logger.LogInformation($"claim hasValue: <{optionClaim.HasValue}>"); var value = optionClaim.ValueOr(new Claim(claimType, string.Empty)).Value; _logger.LogInformation($"value of claim: <{value}>"); if (string.IsNullOrWhiteSpace(value)) { _logger.LogInformation($"RETURN: value (<{value}>) is null, empty, or whitespace"); return; } if (extractedQueryParameter == value) { _logger.LogInformation($"RETURN: extractedQueryParameter(<{extractedQueryParameter}>) equals value(<{value}>)"); return; } var encodedUrl = HttpUtility.UrlEncode(_navigationManager.Uri); _logger.LogInformation($"encodedUrl is: <{encodedUrl}>"); _logger.LogInformation($"Navigating to: <{AppConstants.LogoutUrlAbsolutePath}?redirectPath={encodedUrl}>"); _navigationManager.NavigateTo($"{AppConstants.LogoutUrlAbsolutePath}?redirectPath={encodedUrl}", true); }
private void LoadCurrentReservationId() => _currentReservationId = UrlQueryParameterExtractor.ExtractQueryParameterFromManager(NavigationManager, AppConstants.ReservationIdQueryParameter);