Why does the registration page keep redirecting to the login page as soon as button pressed ?
Chcoflex opened this issue · comments
When I use the Register page, I would like to keep it there to display errors, such as duplicate email address. But for some reason, that I don't understand, it always, always, redirects to the login page as soon as the register button is pressed, regardless of the errors.
Any idea on how to keep it on page ?
I tracked it down to the JwtAuthenticationHeaderHandler
I couldn't find a better way to avoid the GetAccessTokenAsync() other than to add a list of constants to avoid.
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// List of Anonymous API endpoints that should bypass token handling
bool shouldBypassTokenHandling = BypassedEndpoints.Endpoints.Any(endpoint =>
request.RequestUri?.AbsolutePath.Contains(endpoint, StringComparison.OrdinalIgnoreCase) == true);
if (request.RequestUri?.AbsolutePath.Contains("/tokens") is not true && !shouldBypassTokenHandling)
{
if (await _tokenProviderAccessor.TokenProvider.GetAccessTokenAsync() is string token)
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
else
{
_navigation.NavigateTo("/login");
}
}
return await base.SendAsync(request, cancellationToken);
}