Merge pull request #7 from Shchoholiev/bug/SA-142-fix-login-page-loop

SA-142 login loop fixed
This commit is contained in:
Mykhailo Bilodid 2023-11-01 17:58:30 +02:00 committed by GitHub
commit 7224f7c60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -15,7 +15,7 @@ public static class DependencyInjectionExtension
client.BaseAddress = new Uri(apiUrl + "api/"); client.BaseAddress = new Uri(apiUrl + "api/");
}); });
services.AddScoped<GraphQLHttpClient>(p => services.AddSingleton<GraphQLHttpClient>(p =>
new GraphQLHttpClient(apiUrl + "graphql", new NewtonsoftJsonSerializer()) new GraphQLHttpClient(apiUrl + "graphql", new NewtonsoftJsonSerializer())
); );

View File

@ -14,6 +14,8 @@ public class GlobalUserMiddleware
} }
public async Task InvokeAsync(HttpContext httpContext, AuthenticationService authenticationService, ApiClient apiClient) public async Task InvokeAsync(HttpContext httpContext, AuthenticationService authenticationService, ApiClient apiClient)
{
if (httpContext.Request.Path != "/login")
{ {
try try
{ {
@ -32,6 +34,7 @@ public class GlobalUserMiddleware
httpContext.Response.Cookies.Delete("accessToken"); httpContext.Response.Cookies.Delete("accessToken");
httpContext.Response.Redirect("/login"); httpContext.Response.Redirect("/login");
} }
}
await _next(httpContext); await _next(httpContext);
} }
} }