From 496362eab2c6e9c4d3fadd7508e14bd477df6492 Mon Sep 17 00:00:00 2001 From: jcarlosmanuel Date: Fri, 20 May 2022 14:11:43 -0500 Subject: [PATCH] Update JwtAuthenticationHeaderHandler.cs allow pages with anonymous access, show validations --- .../Auth/Jwt/JwtAuthenticationHeaderHandler.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Client.Infrastructure/Auth/Jwt/JwtAuthenticationHeaderHandler.cs b/src/Client.Infrastructure/Auth/Jwt/JwtAuthenticationHeaderHandler.cs index 69c33f67..d4526093 100644 --- a/src/Client.Infrastructure/Auth/Jwt/JwtAuthenticationHeaderHandler.cs +++ b/src/Client.Infrastructure/Auth/Jwt/JwtAuthenticationHeaderHandler.cs @@ -16,8 +16,10 @@ public JwtAuthenticationHeaderHandler(IAccessTokenProviderAccessor tokenProvider protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - // skip token endpoints - if (request.RequestUri?.AbsolutePath.Contains("/tokens") is not true) + // skip token endpoints and pages with attribute [AllowAnonymous] + if (request.RequestUri?.AbsolutePath.Contains("/tokens") is not true && + request.RequestUri?.AbsolutePath.Contains("/self-register") is not true && + request.RequestUri?.AbsolutePath.Contains("/forgot-password") is not true) { if (await _tokenProviderAccessor.TokenProvider.GetAccessTokenAsync() is string token) { @@ -31,4 +33,4 @@ protected override async Task SendAsync(HttpRequestMessage return await base.SendAsync(request, cancellationToken); } -} \ No newline at end of file +}