diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs deleted file mode 100644 index 3d27a364..00000000 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using EShopOnAbp.Shared.Hosting.AspNetCore; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -using Volo.Abp.Guids; - -namespace EShopOnAbp.PublicWeb.Components.AnonymousUser; - -/* TODO: Convert this to an ASP.NET Core middleware */ -[Widget( - AutoInitialize = true -)] -public class AnonymousUserViewComponent : AbpViewComponent -{ - private readonly ILogger _logger; - private readonly IGuidGenerator _guidGenerator; - - public AnonymousUserViewComponent(ILogger logger, IGuidGenerator guidGenerator) - { - _logger = logger; - _guidGenerator = guidGenerator; - } - - public async Task InvokeAsync() - { - // Get anonymous user id from cookie - HttpContext.Request.Cookies.TryGetValue(EShopConstants.AnonymousUserClaimName, - out string anonymousUserId); - _logger.LogInformation($"========= Anonymous User Id from Cookie:{anonymousUserId} ========= "); - - // Generate new id for anonymous user - if (string.IsNullOrEmpty(anonymousUserId)) - { - anonymousUserId = _guidGenerator.Create().ToString(); - HttpContext.Response.Cookies.Append(EShopConstants.AnonymousUserClaimName, anonymousUserId, - new CookieOptions - { - SameSite = SameSiteMode.Lax - }); - _logger.LogInformation( - $"========= Generated new User Id:{anonymousUserId} ========= APPENDED TO COOKIE ====== "); - } - return await Task.FromResult(View("~/Components/AnonymousUser/Default.cshtml")); - } -} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/Default.cshtml deleted file mode 100644 index 42eb8c53..00000000 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/Default.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/_ViewStart.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/_ViewStart.cshtml index 2f921a29..0372fa28 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/_ViewStart.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/_ViewStart.cshtml @@ -1,7 +1,5 @@ -@using EShopOnAbp.PublicWeb.Components.AnonymousUser -@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ Layout = ThemeManager.CurrentTheme.GetPublicLayout(); -} -@await Component.InvokeAsync(typeof(AnonymousUserViewComponent)) \ No newline at end of file +} \ No newline at end of file