Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Grand.Infrastructure.Configuration;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.Net.Http.Headers;

Expand Down Expand Up @@ -35,7 +34,7 @@ public virtual async Task<Customer> GetAuthenticatedCustomer()
if (string.IsNullOrEmpty(authHeader))
return null;

if (IsApiFrontAuthenticated())
if (await IsApiFrontAuthenticated())
{
customer = await ApiCustomer();
return customer;
Expand All @@ -56,13 +55,10 @@ public virtual async Task<Customer> GetAuthenticatedCustomer()

return customer;
}
private bool IsApiFrontAuthenticated()
private async Task<bool> IsApiFrontAuthenticated()
{
var endpoint = _httpContextAccessor.HttpContext.GetEndpoint();
if (endpoint == null) return false;

var authorizeAttributes = endpoint.Metadata.GetOrderedMetadata<AuthorizeAttribute>();
return authorizeAttributes.Any(attr => attr.AuthenticationSchemes?.Contains(FrontendAPIConfig.AuthenticationScheme) == true);
var authResult = await _httpContextAccessor.HttpContext.AuthenticateAsync(FrontendAPIConfig.AuthenticationScheme);
return authResult.Succeeded;
}


Expand Down
Loading