Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Refactor AccessDenied methods and clean up usings (Log entries created from user input)
KrzysztofPajaka03bef8a04f7
diff --git a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs b/src/Web/Grand.Web.Admin/Controllers/HomeController.csindex 1d4bcf81f..bb98e4823 100644--- a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/HomeController.cs@@ -197,17 +197,16 @@ public class HomeController : BaseAdminControllerreturn Json(result);}- public async Task<IActionResult> AccessDenied(string pageUrl)+ public async Task<IActionResult> AccessDenied(){var currentCustomer = _workContext.CurrentCustomer;if (currentCustomer == null || await _groupService.IsGuest(currentCustomer)){- _logger.LogInformation("Access denied to anonymous request on {PageUrl}", pageUrl);+ _logger.LogInformation("Access denied to anonymous request");return View();}- _logger.LogInformation("Access denied to user #{CurrentCustomerEmail} \'{CurrentCustomerEmail}\' on {PageUrl}",- currentCustomer.Email, currentCustomer.Email, pageUrl);+ _logger.LogInformation("Access denied to user #{CurrentCustomerEmail} \'{CurrentCustomerEmail}\'", currentCustomer.Email, currentCustomer.Email);return View();}diff --git a/src/Web/Grand.Web.Common/Controllers/BaseController.cs b/src/Web/Grand.Web.Common/Controllers/BaseController.csindex 62cae0a9b..72d431af9 100644--- a/src/Web/Grand.Web.Common/Controllers/BaseController.cs+++ b/src/Web/Grand.Web.Common/Controllers/BaseController.cs@@ -4,10 +4,8 @@ using Grand.Web.Common.DataSource;using Grand.Web.Common.Events;using Grand.Web.Common.Extensions;using Grand.Web.Common.Filters;-using Grand.Web.Common.Models;using Grand.Web.Common.Page;using MediatR;-using Microsoft.AspNetCore.Http.Extensions;using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.Filters;using Microsoft.AspNetCore.Mvc.ModelBinding;@@ -216,7 +214,7 @@ public abstract class BaseController : Controller/// <returns>Access denied view</returns>protected IActionResult AccessDeniedView(){- return RedirectToAction("AccessDenied", "Home", new { pageUrl = HttpContext.Request.GetEncodedPathAndQuery() });+ return RedirectToAction("AccessDenied", "Home");}/// <summary>diff --git a/src/Web/Grand.Web.Vendor/Controllers/HomeController.cs b/src/Web/Grand.Web.Vendor/Controllers/HomeController.csindex 290226409..c7b64590f 100644--- a/src/Web/Grand.Web.Vendor/Controllers/HomeController.cs+++ b/src/Web/Grand.Web.Vendor/Controllers/HomeController.cs@@ -44,10 +44,9 @@ public class HomeController : BaseVendorControllerreturn View();}- public IActionResult AccessDenied(string pageUrl)+ public IActionResult AccessDenied(){- _logger.LogInformation("Access denied to user #{CurrentCustomerEmail} on {PageUrl}",- _workContext.CurrentCustomer.Email, pageUrl);+ _logger.LogInformation("Access denied to user #{CurrentCustomerEmail}", _workContext.CurrentCustomer.Email);return View();}