Skip to content

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.

Minor changes Filters

support34188ee74971
diff --git a/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs b/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
index 0c5c76e26..5a4fda32a 100644
--- a/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
@@ -85,8 +85,8 @@ namespace Grand.Web.Common.Filters
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
await next();
-
- if (context?.HttpContext.Request == null)
+
+ if (!DataSettingsManager.DatabaseIsInstalled())
return;
//check request query parameters
@@ -94,9 +94,7 @@ namespace Grand.Web.Common.Filters
if (!request.Query.Any())
return;
- if (!DataSettingsManager.DatabaseIsInstalled())
- return;
-
+
//try to find by ID
var affiliateIds = request.Query[IdQueryParameterName];
if (affiliateIds.Any())
diff --git a/src/Web/Grand.Web.Common/Filters/ArgumentNameFilterAttribute.cs b/src/Web/Grand.Web.Common/Filters/ArgumentNameFilterAttribute.cs
index 7442c9196..a4477397d 100644
--- a/src/Web/Grand.Web.Common/Filters/ArgumentNameFilterAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/ArgumentNameFilterAttribute.cs
@@ -9,11 +9,7 @@ namespace Grand.Web.Common.Filters
public override void OnActionExecuting(ActionExecutingContext context)
{
- if (context?.HttpContext.Request == null)
- return;
-
context.ActionArguments[Argument] = context.HttpContext.Request.Form.Keys.Any(key => key.Equals(KeyName));
-
}
}
}
diff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
index 673cbec7f..b66c15ada 100644
--- a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
@@ -93,7 +93,7 @@ namespace Grand.Web.Common.Filters
//whether current customer is vendor
if (await _groupService.IsVendor(_workContext.CurrentCustomer) || _workContext.CurrentVendor is not null)
- filterContext.Result = new RedirectToRouteResult("AdminLogin", new RouteValueDictionary());;
+ filterContext.Result = new RedirectToRouteResult("AdminLogin", new RouteValueDictionary());
//get allowed IP addresses
var ipAddresses = _securitySettings.AdminAreaAllowedIpAddresses;
diff --git a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
index c890a69f6..653a1e4d5 100644
--- a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
@@ -65,8 +65,6 @@ namespace Grand.Web.Common.Filters
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
await next();
- if (context?.HttpContext?.Request == null)
- return;
if (!DataSettingsManager.DatabaseIsInstalled())
return;
diff --git a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
index 87c8363a8..78e793033 100644
--- a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
@@ -60,12 +60,6 @@ namespace Grand.Web.Common.Filters
/// <param name="next">Action execution delegate</param>
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
- if (context?.HttpContext?.Request == null)
- {
- await next();
- return;
- }
-
if (!DataSettingsManager.DatabaseIsInstalled())
{
await next();
@@ -94,7 +88,7 @@ namespace Grand.Web.Common.Filters
}
//check whether current page URL is already localized URL
- var pageUrl = context.HttpContext?.Request?.GetEncodedPathAndQuery();
+ var pageUrl = context.HttpContext.Request?.GetEncodedPathAndQuery();
if (await IsLocalized(pageUrl, context.HttpContext.Request.PathBase))
{
await next();
@@ -107,7 +101,7 @@ namespace Grand.Web.Common.Filters
private async Task<bool> IsLocalized(string url, PathString pathBase)
{
- var _ = new PathString(url).StartsWithSegments(pathBase, out PathString result);
+ _ = new PathString(url).StartsWithSegments(pathBase, out PathString result);
url = WebUtility.UrlDecode(result);
var firstSegment = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? string.Empty;
diff --git a/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs b/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
index 44a490245..148291d0c 100644
--- a/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
@@ -53,9 +53,7 @@ namespace Grand.Web.Common.Filters
/// <param name="context">A context for action filters</param>
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
{
- if (context?.HttpContext.Request == null)
- return;
-
+
if (!DataSettingsManager.DatabaseIsInstalled())
return;