|
|
|
@ -5,7 +5,6 @@ using System; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
namespace EShopOnAbp.PublicWeb.Basket |
|
|
|
@ -16,20 +15,17 @@ namespace EShopOnAbp.PublicWeb.Basket |
|
|
|
|
|
|
|
private readonly IHttpContextAccessor httpContextAccessor; |
|
|
|
protected readonly ILogger<UserBasketProvider> logger; |
|
|
|
protected readonly IGuidGenerator guidGenerator; |
|
|
|
protected readonly IBasketAppService basketAppService; |
|
|
|
protected readonly ICurrentUser currentUser; |
|
|
|
|
|
|
|
public UserBasketProvider( |
|
|
|
IHttpContextAccessor httpContextAccessor, |
|
|
|
ILogger<UserBasketProvider> logger, |
|
|
|
IGuidGenerator guidGenerator, |
|
|
|
IBasketAppService basketAppService, |
|
|
|
ICurrentUser currentUser) |
|
|
|
{ |
|
|
|
this.httpContextAccessor = httpContextAccessor; |
|
|
|
this.logger = logger; |
|
|
|
this.guidGenerator = guidGenerator; |
|
|
|
this.basketAppService = basketAppService; |
|
|
|
this.currentUser = currentUser; |
|
|
|
} |
|
|
|
@ -44,14 +40,14 @@ namespace EShopOnAbp.PublicWeb.Basket |
|
|
|
|
|
|
|
if (!currentUser.IsAuthenticated) |
|
|
|
{ |
|
|
|
logger.LogInformation( |
|
|
|
$"========= Get Basket for Anonymous UserId:{anonymousUserId} ========= ====== "); |
|
|
|
logger.LogInformation($"Getting basket for anonymous user id:{anonymousUserId}."); |
|
|
|
return await basketAppService.GetByAnonymousUserIdAsync(Guid.Parse(anonymousUserId)); |
|
|
|
} |
|
|
|
|
|
|
|
//TODO: Merge with anonymously stored cart if exist
|
|
|
|
var userClaimValue = currentUser.FindClaimValue(EShopConstants.AnonymousUserClaimName); |
|
|
|
|
|
|
|
// Fall-back for having trouble when setting claim on user login
|
|
|
|
if (string.IsNullOrEmpty(userClaimValue)) |
|
|
|
{ |
|
|
|
return await basketAppService.GetAsync(); |
|
|
|
|