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.

Created new class with AccessControlConfig settings and moved properties from PerformanceConfig, setting IgnoreAcl/IgnoreStoreLimitations

supporte11995818ee9
diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
index 973ab4f60..f69d661e0 100644
--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
@@ -4,7 +4,7 @@ using Grand.Domain;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Data;
-using Grand.SharedKernel.Extensions;
+using Grand.Infrastructure.Configuration;
using MediatR;
namespace Grand.Business.Catalog.Queries.Handlers
@@ -14,17 +14,19 @@ namespace Grand.Business.Catalog.Queries.Handlers
{
private readonly IRepository<Product> _productRepository;
private readonly ISpecificationAttributeService _specificationAttributeService;
-
+ private readonly AccessControlConfig _accessControlConfig;
private readonly CatalogSettings _catalogSettings;
public GetSearchProductsQueryHandler(
IRepository<Product> productRepository,
ISpecificationAttributeService specificationAttributeService,
- CatalogSettings catalogSettings)
+ CatalogSettings catalogSettings,
+ AccessControlConfig accessControlConfig)
{
_productRepository = productRepository;
_specificationAttributeService = specificationAttributeService;
_catalogSettings = catalogSettings;
+ _accessControlConfig = accessControlConfig;
}
public async Task<(IPagedList<Product> products, IList<string> filterableSpecificationAttributeOptionIds)>
@@ -250,14 +252,14 @@ namespace Grand.Business.Catalog.Queries.Handlers
}
}
- if (!request.ShowHidden && !CommonHelper.IgnoreAcl)
+ if (!request.ShowHidden && !_accessControlConfig.IgnoreAcl)
{
query = from p in query
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!string.IsNullOrEmpty(request.StoreId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(request.StoreId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = query.Where(x => x.Stores.Any(y => y == request.StoreId) || !x.LimitedToStores);
}
diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs
index e83094fc8..6dbca7a77 100644
--- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs
@@ -6,8 +6,8 @@ using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Brands
@@ -23,7 +23,8 @@ namespace Grand.Business.Catalog.Services.Brands
private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -34,12 +35,13 @@ namespace Grand.Business.Catalog.Services.Brands
public BrandService(ICacheBase cacheBase,
IRepository<Brand> brandRepository,
IWorkContext workContext,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_brandRepository = brandRepository;
_workContext = workContext;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -68,9 +70,9 @@ namespace Grand.Business.Catalog.Services.Brands
if (!string.IsNullOrWhiteSpace(brandName))
query = query.Where(m => m.Name != null && m.Name.ToLower().Contains(brandName.ToLower()));
- if (!CommonHelper.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations))
+ if (!_accessControlConfig.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!showHidden && !CommonHelper.IgnoreAcl)
+ if (!showHidden && !_accessControlConfig.IgnoreAcl)
{
//Limited to customer groups rules
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -79,7 +81,7 @@ namespace Grand.Business.Catalog.Services.Brands
select p;
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores rules
query = from p in query
diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs
index eab78bad6..95568c117 100644
--- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs
@@ -8,8 +8,8 @@ using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Categories
@@ -26,7 +26,8 @@ namespace Grand.Business.Catalog.Services.Categories
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
private readonly IAclService _aclService;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -39,17 +40,20 @@ namespace Grand.Business.Catalog.Services.Categories
/// <param name="workContext">Work context</param>
/// <param name="mediator">Mediator</param>
/// <param name="aclService">ACL service</param>
+ /// <param name="accessControlConfig"></param>
public CategoryService(ICacheBase cacheBase,
IRepository<Category> categoryRepository,
IWorkContext workContext,
IMediator mediator,
- IAclService aclService)
+ IAclService aclService,
+ AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_categoryRepository = categoryRepository;
_workContext = workContext;
_mediator = mediator;
_aclService = aclService;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -80,9 +84,9 @@ namespace Grand.Business.Catalog.Services.Categories
if (parentId != null)
query = query.Where(m => m.ParentCategoryId == parentId);
- if (!CommonHelper.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations))
+ if (!_accessControlConfig.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!showHidden && !CommonHelper.IgnoreAcl)
+ if (!showHidden && !_accessControlConfig.IgnoreAcl)
{
//Limited to customer group (access control list)
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -90,7 +94,7 @@ namespace Grand.Business.Catalog.Services.Categories
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores rule
query = from p in query
@@ -117,10 +121,10 @@ namespace Grand.Business.Catalog.Services.Categories
query = query.Where(c => c.Published && c.IncludeInMenu);
- switch (CommonHelper.IgnoreAcl)
+ switch (_accessControlConfig.IgnoreAcl)
{
case true when
- string.IsNullOrEmpty(_workContext.CurrentStore.Id) || CommonHelper.IgnoreStoreLimitations:
+ string.IsNullOrEmpty(_workContext.CurrentStore.Id) || _accessControlConfig.IgnoreStoreLimitations:
return await Task.FromResult(query.ToList());
case false:
{
@@ -133,7 +137,7 @@ namespace Grand.Business.Catalog.Services.Categories
}
}
- if (!string.IsNullOrEmpty(_workContext.CurrentStore.Id) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(_workContext.CurrentStore.Id) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores rule
query = from p in query
@@ -162,9 +166,9 @@ namespace Grand.Business.Catalog.Services.Categories
if (!showHidden)
query = query.Where(c => c.Published);
- if (!showHidden && (!CommonHelper.IgnoreAcl || !CommonHelper.IgnoreStoreLimitations))
+ if (!showHidden && (!_accessControlConfig.IgnoreAcl || !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
//Limited to customer groups rules
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -172,7 +176,7 @@ namespace Grand.Business.Catalog.Services.Categories
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores rules
query = from p in query
diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs
index bc7112be2..6bb39813b 100644
--- a/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs
@@ -7,8 +7,8 @@ using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Categories
@@ -19,17 +19,19 @@ namespace Grand.Business.Catalog.Services.Categories
private readonly ICacheBase _cacheBase;
private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
public ProductCategoryService(
IRepository<Product> productRepository,
ICacheBase cacheBase,
IWorkContext workContext,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_productRepository = productRepository;
_cacheBase = cacheBase;
_workContext = workContext;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
/// <summary>
@@ -51,9 +53,9 @@ namespace Grand.Business.Catalog.Services.Categories
{
var query = _productRepository.Table.Where(x => x.ProductCategories.Any(y => y.CategoryId == categoryId));
- if (!showHidden && (!CommonHelper.IgnoreAcl || !CommonHelper.IgnoreStoreLimitations))
+ if (!showHidden && (!_accessControlConfig.IgnoreAcl || !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
//Limited to customer groups
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -61,7 +63,7 @@ namespace Grand.Business.Catalog.Services.Categories
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores
var currentStoreId = _workContext.CurrentStore.Id;
diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs
index f00df85c9..c66e35ba9 100644
--- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs
@@ -7,8 +7,8 @@ using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Collections
@@ -25,7 +25,8 @@ namespace Grand.Business.Catalog.Services.Collections
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
private readonly IAclService _aclService;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -37,13 +38,14 @@ namespace Grand.Business.Catalog.Services.Collections
IRepository<Collection> collectionRepository,
IWorkContext workContext,
IMediator mediator,
- IAclService aclService)
+ IAclService aclService, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_collectionRepository = collectionRepository;
_workContext = workContext;
_mediator = mediator;
_aclService = aclService;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -73,9 +75,9 @@ namespace Grand.Business.Catalog.Services.Collections
if (!string.IsNullOrWhiteSpace(collectionName))
query = query.Where(m => m.Name != null && m.Name.ToLower().Contains(collectionName.ToLower()));
- if (!CommonHelper.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations))
+ if (!_accessControlConfig.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!showHidden && !CommonHelper.IgnoreAcl)
+ if (!showHidden && !_accessControlConfig.IgnoreAcl)
{
//Limited to customer groups rules
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -84,7 +86,7 @@ namespace Grand.Business.Catalog.Services.Collections
select p;
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Limited to stores rules
query = from p in query
diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs
index b8c3f6fda..d52396ecc 100644
--- a/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs
@@ -7,8 +7,8 @@ using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Collections
@@ -21,7 +21,8 @@ namespace Grand.Business.Catalog.Services.Collections
private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -29,12 +30,13 @@ namespace Grand.Business.Catalog.Services.Collections
public ProductCollectionService(ICacheBase cacheBase,
IRepository<Product> productRepository,
IWorkContext workContext,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_productRepository = productRepository;
_workContext = workContext;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -55,9 +57,9 @@ namespace Grand.Business.Catalog.Services.Collections
{
var query = _productRepository.Table.Where(x => x.ProductCollections.Any(y => y.CollectionId == collectionId));
- if (!showHidden && (!CommonHelper.IgnoreAcl || !CommonHelper.IgnoreStoreLimitations))
+ if (!showHidden && (!_accessControlConfig.IgnoreAcl || !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
//ACL (access control list)
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -65,7 +67,7 @@ namespace Grand.Business.Catalog.Services.Collections
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
+ if (!_accessControlConfig.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
{
//Store acl
query = from p in query
diff --git a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs
index 7e6b6dc17..22220e7c7 100644
--- a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs
@@ -1,6 +1,5 @@
using Grand.Business.Core.Interfaces.Catalog.Discounts;
using Grand.Business.Core.Utilities.Catalog;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
@@ -11,8 +10,8 @@ using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Catalog.Services.Discounts
@@ -33,7 +32,8 @@ namespace Grand.Business.Catalog.Services.Discounts
private readonly IEnumerable<IDiscountProvider> _discountProviders;
private readonly IEnumerable<IDiscountAmountProvider> _discountAmountProviders;
private readonly IMediator _mediator;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -48,7 +48,7 @@ namespace Grand.Business.Catalog.Services.Discounts
IWorkContext workContext,
IEnumerable<IDiscountProvider> discountProviders,
IEnumerable<IDiscountAmountProvider> discountAmountProviders,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_discountRepository = discountRepository;
@@ -58,6 +58,7 @@ namespace Grand.Business.Catalog.Services.Discounts
_discountProviders = discountProviders;
_discountAmountProviders = discountAmountProviders;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -95,7 +96,7 @@ namespace Grand.Business.Catalog.Services.Discounts
&& (!d.EndDateUtc.HasValue || d.EndDateUtc >= nowUtc)
&& d.IsEnabled);
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
diff --git a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs
index 259258d8a..79fd26773 100644
--- a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs
@@ -5,8 +5,8 @@ using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Checkout.Services.CheckoutAttributes
@@ -22,7 +22,8 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
private readonly IWorkContext _workContext;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -34,12 +35,13 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes
ICacheBase cacheBase,
IRepository<CheckoutAttribute> checkoutAttributeRepository,
IMediator mediator,
- IWorkContext workContext)
+ IWorkContext workContext, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_checkoutAttributeRepository = checkoutAttributeRepository;
_mediator = mediator;
_workContext = workContext;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -63,10 +65,10 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes
query = query.OrderBy(c => c.DisplayOrder);
- if ((!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations) ||
- (!ignoreAcl && !CommonHelper.IgnoreAcl))
+ if ((!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations) ||
+ (!ignoreAcl && !_accessControlConfig.IgnoreAcl))
{
- if (!ignoreAcl && !CommonHelper.IgnoreAcl)
+ if (!ignoreAcl && !_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -74,7 +76,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes
select p;
}
//Store acl
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = from p in query
where !p.LimitedToStores || p.Stores.Contains(storeId)
diff --git a/src/Business/Grand.Business.Cms/Services/BlogService.cs b/src/Business/Grand.Business.Cms/Services/BlogService.cs
index 832ec7eb5..a646038da 100644
--- a/src/Business/Grand.Business.Cms/Services/BlogService.cs
+++ b/src/Business/Grand.Business.Cms/Services/BlogService.cs
@@ -2,8 +2,8 @@ using Grand.Business.Core.Interfaces.Cms;
using Grand.Domain;
using Grand.Domain.Blogs;
using Grand.Domain.Data;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Cms.Services
@@ -19,6 +19,7 @@ namespace Grand.Business.Cms.Services
private readonly IRepository<BlogComment> _blogCommentRepository;
private readonly IRepository<BlogCategory> _blogCategoryRepository;
private readonly IRepository<BlogProduct> _blogProductRepository;
+ private readonly AccessControlConfig _accessControlConfig;
private readonly IMediator _mediator;
#endregion
@@ -29,13 +30,14 @@ namespace Grand.Business.Cms.Services
IRepository<BlogComment> blogCommentRepository,
IRepository<BlogCategory> blogCategoryRepository,
IRepository<BlogProduct> blogProductRepository,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_blogPostRepository = blogPostRepository;
_blogCommentRepository = blogCommentRepository;
_blogCategoryRepository = blogCategoryRepository;
_blogProductRepository = blogProductRepository;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -101,7 +103,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(b => !b.EndDateUtc.HasValue || b.EndDateUtc >= utcNow);
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = query.Where(b => b.Stores.Contains(storeId) || !b.LimitedToStores);
}
@@ -339,7 +341,7 @@ namespace Grand.Business.Cms.Services
var query = from c in _blogCategoryRepository.Table
select c;
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = query.Where(b => b.Stores.Contains(storeId) || !b.LimitedToStores);
}
diff --git a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
index bfbc03930..b0fcf0cf5 100644
--- a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
+++ b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
@@ -6,8 +6,8 @@ using Grand.Domain.Knowledgebase;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Cms.Services
@@ -20,7 +20,8 @@ namespace Grand.Business.Cms.Services
private readonly IMediator _mediator;
private readonly IWorkContext _workContext;
private readonly ICacheBase _cacheBase;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
/// <summary>
/// Ctor
/// </summary>
@@ -30,8 +31,7 @@ namespace Grand.Business.Cms.Services
IRepository<KnowledgebaseArticleComment> articleCommentRepository,
IMediator mediator,
IWorkContext workContext,
- ICacheBase cacheBase
- )
+ ICacheBase cacheBase, AccessControlConfig accessControlConfig)
{
_knowledgebaseCategoryRepository = knowledgebaseCategoryRepository;
_knowledgebaseArticleRepository = knowledgebaseArticleRepository;
@@ -39,6 +39,7 @@ namespace Grand.Business.Cms.Services
_mediator = mediator;
_workContext = workContext;
_cacheBase = cacheBase;
+ _accessControlConfig = accessControlConfig;
}
/// <summary>
@@ -101,7 +102,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
query = query.Where(x => x.Id == id);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
//Limited to customer groups rules
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
@@ -110,7 +111,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -169,7 +170,7 @@ namespace Grand.Business.Cms.Services
{
var query = from p in _knowledgebaseArticleRepository.Table
select p;
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -177,7 +178,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
+ if (!_accessControlConfig.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
{
//Limited to stores rules
query = from p in query
@@ -254,7 +255,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -262,7 +263,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -291,7 +292,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -299,7 +300,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -328,7 +329,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
query = query.Where(x => x.Id == id);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -336,7 +337,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -364,7 +365,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
query = query.Where(x => x.ParentCategoryId == categoryId);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -372,7 +373,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -403,7 +404,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
|| p.Name.ToLower().Contains(keyword.ToLower()) || p.Content.ToLower().Contains(keyword.ToLower()));
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -411,7 +412,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -441,7 +442,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
|| p.Name.ToLower().Contains(keyword.ToLower()) || p.Description.ToLower().Contains(keyword.ToLower()));
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -449,7 +450,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
@@ -478,7 +479,7 @@ namespace Grand.Business.Cms.Services
query = query.Where(x => x.Published);
query = query.Where(x => x.ShowOnHomepage);
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -486,7 +487,7 @@ namespace Grand.Business.Cms.Services
select p;
}
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
diff --git a/src/Business/Grand.Business.Cms/Services/NewsService.cs b/src/Business/Grand.Business.Cms/Services/NewsService.cs
index f476817f7..042d07420 100644
--- a/src/Business/Grand.Business.Cms/Services/NewsService.cs
+++ b/src/Business/Grand.Business.Cms/Services/NewsService.cs
@@ -4,8 +4,8 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Domain.News;
using Grand.Infrastructure;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Cms.Services
@@ -20,18 +20,20 @@ namespace Grand.Business.Cms.Services
private readonly IRepository<NewsItem> _newsItemRepository;
private readonly IMediator _mediator;
private readonly IWorkContext _workContext;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
public NewsService(IRepository<NewsItem> newsItemRepository,
IMediator mediator,
- IWorkContext workContext)
+ IWorkContext workContext, AccessControlConfig accessControlConfig)
{
_newsItemRepository = newsItemRepository;
_mediator = mediator;
_workContext = workContext;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -76,10 +78,10 @@ namespace Grand.Business.Cms.Services
query = query.Where(n => !n.EndDateUtc.HasValue || n.EndDateUtc >= utcNow);
}
- if ((!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations) ||
- (!ignoreAcl && !CommonHelper.IgnoreAcl))
+ if ((!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations) ||
+ (!ignoreAcl && !_accessControlConfig.IgnoreAcl))
{
- if (!ignoreAcl && !CommonHelper.IgnoreAcl)
+ if (!ignoreAcl && !_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -87,7 +89,7 @@ namespace Grand.Business.Cms.Services
select p;
}
//Store acl
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = from p in query
where !p.LimitedToStores || p.Stores.Contains(storeId)
diff --git a/src/Business/Grand.Business.Cms/Services/PageService.cs b/src/Business/Grand.Business.Cms/Services/PageService.cs
index 07fd0d8fa..0a2dda6bb 100644
--- a/src/Business/Grand.Business.Cms/Services/PageService.cs
+++ b/src/Business/Grand.Business.Cms/Services/PageService.cs
@@ -6,8 +6,8 @@ using Grand.Domain.Pages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Cms.Services
@@ -24,7 +24,8 @@ namespace Grand.Business.Cms.Services
private readonly IAclService _aclService;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -33,13 +34,14 @@ namespace Grand.Business.Cms.Services
IWorkContext workContext,
IAclService aclService,
IMediator mediator,
- ICacheBase cacheBase)
+ ICacheBase cacheBase, AccessControlConfig accessControlConfig)
{
_pageRepository = pageRepository;
_workContext = workContext;
_aclService = aclService;
_mediator = mediator;
_cacheBase = cacheBase;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -102,10 +104,10 @@ namespace Grand.Business.Cms.Services
query = query.OrderBy(t => t.DisplayOrder).ThenBy(t => t.SystemName);
- if ((string.IsNullOrEmpty(storeId) || CommonHelper.IgnoreStoreLimitations) &&
- (ignoreAcl || CommonHelper.IgnoreAcl)) return await Task.FromResult(query.ToList());
+ if ((string.IsNullOrEmpty(storeId) || _accessControlConfig.IgnoreStoreLimitations) &&
+ (ignoreAcl || _accessControlConfig.IgnoreAcl)) return await Task.FromResult(query.ToList());
{
- if (!ignoreAcl && !CommonHelper.IgnoreAcl)
+ if (!ignoreAcl && !_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -113,7 +115,7 @@ namespace Grand.Business.Cms.Services
select p;
}
//Store acl
- if (string.IsNullOrEmpty(storeId) || CommonHelper.IgnoreStoreLimitations)
+ if (string.IsNullOrEmpty(storeId) || _accessControlConfig.IgnoreStoreLimitations)
return await Task.FromResult(query.ToList());
query = from p in query
where !p.LimitedToStores || p.Stores.Contains(storeId)
diff --git a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs b/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs
index f25a233f7..f06d5b208 100644
--- a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs
+++ b/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs
@@ -4,8 +4,8 @@ using Grand.Domain.Data;
using Grand.Domain.Directory;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Common.Services.Directory
@@ -20,7 +20,8 @@ namespace Grand.Business.Common.Services.Directory
private readonly IRepository<Country> _countryRepository;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -31,12 +32,15 @@ namespace Grand.Business.Common.Services.Directory
/// <param name="countryRepository">Country repository</param>
/// <param name="mediator">Mediator</param>
/// <param name="cacheBase">Cache manager</param>
+ /// <param name="accessControlConfig">Access control</param>
public CountryService(
IRepository<Country> countryRepository,
IMediator mediator,
- ICacheBase cacheBase)
+ ICacheBase cacheBase,
+ AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
+ _accessControlConfig = accessControlConfig;
_countryRepository = countryRepository;
_mediator = mediator;
}
@@ -64,7 +68,7 @@ namespace Grand.Business.Common.Services.Directory
if (!showHidden)
query = query.Where(c => c.Published);
- if (!showHidden && !CommonHelper.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
+ if (!showHidden && !_accessControlConfig.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
{
//Store acl
query = from p in query
diff --git a/src/Business/Grand.Business.Common/Services/Security/AclService.cs b/src/Business/Grand.Business.Common/Services/Security/AclService.cs
index 9a9968133..651f2b46a 100644
--- a/src/Business/Grand.Business.Common/Services/Security/AclService.cs
+++ b/src/Business/Grand.Business.Common/Services/Security/AclService.cs
@@ -3,7 +3,7 @@ using Grand.Domain;
using Grand.Domain.Customers;
using Grand.Domain.Permissions;
using Grand.Domain.Stores;
-using Grand.SharedKernel.Extensions;
+using Grand.Infrastructure.Configuration;
namespace Grand.Business.Common.Services.Security
{
@@ -12,14 +12,20 @@ namespace Grand.Business.Common.Services.Security
/// </summary>
public class AclService : IAclService
{
+ #region Fields
+
+ private readonly AccessControlConfig _accessControlConfig;
+
+ #endregion
+
#region Ctor
/// <summary>
/// Ctor
/// </summary>
- public AclService()
+ public AclService(AccessControlConfig accessControlConfig)
{
-
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -45,7 +51,7 @@ namespace Grand.Business.Common.Services.Security
if (!entity.LimitedToGroups)
return true;
- return CommonHelper.IgnoreAcl || customer.Groups.Any(role1 => entity.CustomerGroups.Any(role2Id => role1 == role2Id));
+ return _accessControlConfig.IgnoreAcl || customer.Groups.Any(role1 => entity.CustomerGroups.Any(role2Id => role1 == role2Id));
}
/// <summary>
@@ -64,7 +70,7 @@ namespace Grand.Business.Common.Services.Security
//return true if no store specified/found
return true;
- if (CommonHelper.IgnoreStoreLimitations)
+ if (_accessControlConfig.IgnoreStoreLimitations)
return true;
return !entity.LimitedToStores || entity.Stores.Any(storeIdWithAccess => storeId == storeIdWithAccess);
diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs
index a3156dc27..d62fb7508 100644
--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs
@@ -5,8 +5,8 @@ using Grand.Domain.Messages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Marketing.Services.Contacts
@@ -22,7 +22,8 @@ namespace Grand.Business.Marketing.Services.Contacts
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
private readonly IWorkContext _workContext;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Ctor
@@ -33,12 +34,13 @@ namespace Grand.Business.Marketing.Services.Contacts
public ContactAttributeService(ICacheBase cacheBase,
IRepository<ContactAttribute> contactAttributeRepository,
IMediator mediator,
- IWorkContext workContext)
+ IWorkContext workContext, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_contactAttributeRepository = contactAttributeRepository;
_mediator = mediator;
_workContext = workContext;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -81,9 +83,9 @@ namespace Grand.Business.Marketing.Services.Contacts
query = query.OrderBy(c => c.DisplayOrder);
- if ((string.IsNullOrEmpty(storeId) || CommonHelper.IgnoreStoreLimitations) &&
- (ignoreAcl || CommonHelper.IgnoreAcl)) return await Task.FromResult(query.ToList());
- if (!ignoreAcl && !CommonHelper.IgnoreAcl)
+ if ((string.IsNullOrEmpty(storeId) || _accessControlConfig.IgnoreStoreLimitations) &&
+ (ignoreAcl || _accessControlConfig.IgnoreAcl)) return await Task.FromResult(query.ToList());
+ if (!ignoreAcl && !_accessControlConfig.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
query = from p in query
@@ -91,7 +93,7 @@ namespace Grand.Business.Marketing.Services.Contacts
select p;
}
//Store acl
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
query = from p in query
where !p.LimitedToStores || p.Stores.Contains(storeId)
diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs
index fc6f81bf8..ec4981d96 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs
@@ -4,8 +4,8 @@ using Grand.Domain.Courses;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Domain.Orders;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Marketing.Services.Courses
@@ -15,14 +15,17 @@ namespace Grand.Business.Marketing.Services.Courses
private readonly IRepository<Course> _courseRepository;
private readonly IRepository<Order> _orderRepository;
private readonly IMediator _mediator;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
public CourseService(IRepository<Course> courseRepository,
IRepository<Order> orderRepository,
- IMediator mediator)
+ IMediator mediator,
+ AccessControlConfig accessControlConfig)
{
_courseRepository = courseRepository;
_orderRepository = orderRepository;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
public virtual async Task Delete(Course course)
@@ -51,9 +54,9 @@ namespace Grand.Business.Marketing.Services.Courses
query = query.Where(c => c.Published);
- if (!CommonHelper.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations))
+ if (!_accessControlConfig.IgnoreAcl || (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations))
{
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
{
//ACL (access control list)
var allowedCustomerGroupsIds = customer.GetCustomerGroupIds();
@@ -61,7 +64,7 @@ namespace Grand.Business.Marketing.Services.Courses
where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
select p;
}
- if (!string.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations)
+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)
{
//Store acl
query = from p in query
diff --git a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs
index db48ad254..5a5989248 100644
--- a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs
+++ b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs
@@ -4,8 +4,8 @@ using Grand.Domain.Data;
using Grand.Domain.Messages;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Extensions;
-using Grand.SharedKernel.Extensions;
using MediatR;
namespace Grand.Business.Messages.Services
@@ -18,6 +18,7 @@ namespace Grand.Business.Messages.Services
private readonly IAclService _aclService;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
+ private readonly AccessControlConfig _accessControlConfig;
#endregion
@@ -29,12 +30,13 @@ namespace Grand.Business.Messages.Services
public MessageTemplateService(ICacheBase cacheBase,
IAclService aclService,
IRepository<MessageTemplate> messageTemplateRepository,
- IMediator mediator)
+ IMediator mediator, AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_aclService = aclService;
_messageTemplateRepository = messageTemplateRepository;
_mediator = mediator;
+ _accessControlConfig = accessControlConfig;
}
#endregion
@@ -151,7 +153,7 @@ namespace Grand.Business.Messages.Services
query = query.OrderBy(t => t.Name);
//Store acl
- if (string.IsNullOrEmpty(storeId) || CommonHelper.IgnoreStoreLimitations)
+ if (string.IsNullOrEmpty(storeId) || _accessControlConfig.IgnoreStoreLimitations)
return await Task.FromResult(query.ToList());
query = from p in query
diff --git a/src/Core/Grand.Infrastructure/Configuration/AccessControlConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AccessControlConfig.cs
new file mode 100644
index 000000000..4c2a9c63b
--- /dev/null
+++ b/src/Core/Grand.Infrastructure/Configuration/AccessControlConfig.cs
@@ -0,0 +1,15 @@
+namespace Grand.Infrastructure.Configuration;
+
+public class AccessControlConfig
+{
+ /// <summary>
+ /// A value indicating whether to ignore ACL rules (side-wide). It can significantly improve performance when enabled.
+ /// </summary>
+ public bool IgnoreAcl { get; set; }
+
+ /// <summary>
+ /// A value indicating whether to ignore "limit per store" rules (side-wide). It can significantly improve performance when enabled.
+ /// </summary>
+ public bool IgnoreStoreLimitations { get; set; }
+
+}
\ No newline at end of file
diff --git a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
index f1f40a838..47321d5a6 100644
--- a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
@@ -4,17 +4,7 @@ namespace Grand.Infrastructure.Configuration
/// Represents a Performance Config
/// </summary>
public partial class PerformanceConfig
- {
- /// <summary>
- /// A value indicating whether to ignore ACL rules (side-wide). It can significantly improve performance when enabled.
- /// </summary>
- public bool IgnoreAcl { get; set; }
-
- /// <summary>
- /// A value indicating whether to ignore "limit per store" rules (side-wide). It can significantly improve performance when enabled.
- /// </summary>
- public bool IgnoreStoreLimitations { get; set; }
-
+ {
/// <summary>
/// Gets or sets a value indicating whether mini profiler should be displayed in public store (used for debugging)
/// </summary>
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 4bcfd99fc..941d6641e 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -207,6 +207,7 @@ namespace Grand.Infrastructure
services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));
services.StartupConfig<ExtensionsConfig>(configuration.GetSection("Extensions"));
services.StartupConfig<CacheConfig>(configuration.GetSection("Cache"));
+ services.StartupConfig<AccessControlConfig>(configuration.GetSection("AccessControl"));
services.StartupConfig<UrlRewriteConfig>(configuration.GetSection("UrlRewrite"));
services.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));
services.StartupConfig<RabbitConfig>(configuration.GetSection("Rabbit"));
@@ -229,9 +230,6 @@ namespace Grand.Infrastructure
CommonPath.WebHostEnvironment = hostingEnvironment.WebRootPath;
CommonPath.BaseDirectory = hostingEnvironment.ContentRootPath;
- CommonHelper.IgnoreAcl = performanceConfig.IgnoreAcl;
- CommonHelper.IgnoreStoreLimitations = performanceConfig.IgnoreStoreLimitations;
-
services.AddTransient<FluentValidationFilter>();
var mvcCoreBuilder = services.AddMvcCore(options =>
{
diff --git a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
index d95ac50e8..abac4acff 100644
--- a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
+++ b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
@@ -10,16 +10,6 @@ namespace Grand.SharedKernel.Extensions
/// </summary>
public static class CommonHelper
{
- /// <summary>
- /// Gets or sets a value indicating whether to ignore ACL rules (side-wide). It can significantly improve performance when enabled.
- /// </summary>
- public static bool IgnoreAcl { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether to ignore "limit per store" rules (side-wide). It can significantly improve performance when enabled.
- /// </summary>
- public static bool IgnoreStoreLimitations { get; set; }
-
/// <summary>
/// Ensures the subscriber email or throw.
/// </summary>
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs
index b7a5fd9af..081b88719 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Queries/Handlers/GetSearchProductsQueryHandlerTests.cs
@@ -3,6 +3,7 @@ using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
+using Grand.Infrastructure.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
@@ -17,7 +18,7 @@ namespace Grand.Business.Catalog.Tests.Queries.Handlers
public void Init()
{
_repository = new MongoDBRepositoryTest<Product>();
- handler = new GetSearchProductsQueryHandler(_repository, new Mock<ISpecificationAttributeService>().Object, new CatalogSettings() { IgnoreFilterableSpecAttributeOption = true});
+ handler = new GetSearchProductsQueryHandler(_repository, new Mock<ISpecificationAttributeService>().Object, new CatalogSettings() { IgnoreFilterableSpecAttributeOption = true}, new AccessControlConfig());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
index e0e60b74b..ea04f17f9 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
@@ -34,7 +34,7 @@ namespace Grand.Business.Catalog.Tests.Services.Brands
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
+ _brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AccessControlConfig());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
index 19342591f..c14dcec77 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
@@ -5,11 +5,9 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Data;
-using Grand.Domain.Data.Mongo;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Events;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -40,10 +38,10 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _aclServiceMock = new AclService();
+ _aclServiceMock = new AclService(new AccessControlConfig());
_settings = new CatalogSettings();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _categoryService = new CategoryService(_cacheBase, _categoryRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock);
+ _categoryService = new CategoryService(_cacheBase, _categoryRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
index 643162a71..a3a116bcc 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
@@ -6,6 +6,7 @@ using Grand.Domain.Data;
using Grand.Domain.Data.Mongo;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -41,8 +42,8 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_aclServiceMock = new Mock<IAclService>();
_settings = new CatalogSettings();
_categoryService = new CategoryService(_casheManagerMock.Object, _categoryRepositoryMock.Object, _workContextMock.Object,
- _mediatorMock.Object, _aclServiceMock.Object);
- _productCategoryService = new ProductCategoryService(_productRepositoryMock.Object, _casheManagerMock.Object, _workContextMock.Object, _mediatorMock.Object);
+ _mediatorMock.Object, _aclServiceMock.Object, new AccessControlConfig());
+ _productCategoryService = new ProductCategoryService(_productRepositoryMock.Object, _casheManagerMock.Object, _workContextMock.Object, _mediatorMock.Object, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
index fe7c546a0..d7bb988a1 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
@@ -34,7 +34,7 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _productCategoryService = new ProductCategoryService(_repository, _cacheBase, _workContextMock.Object, _mediatorMock.Object);
+ _productCategoryService = new ProductCategoryService(_repository, _cacheBase, _workContextMock.Object, _mediatorMock.Object, new AccessControlConfig());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionServiceTests.cs
index 5d86ff596..2dccd514f 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -33,7 +34,7 @@ namespace Grand.Business.Catalog.Tests.Services.Collections
_aclMock = new Mock<IAclService>();
_settings = new CatalogSettings();
_collectionService = new CollectionService(_cacheMock.Object, _repositoryMock.Object, _workContextMock.Object
- , _mediatorMock.Object, _aclMock.Object);
+ , _mediatorMock.Object, _aclMock.Object, new AccessControlConfig());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
index 40647b6d2..3e47cf22b 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
@@ -34,7 +34,7 @@ namespace Grand.Business.Catalog.Tests.Services.Collections
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _productCollectionService = new ProductCollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
+ _productCollectionService = new ProductCollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AccessControlConfig());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
index 35dc7ea46..3626269ee 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
@@ -53,7 +53,7 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
_discountAmountProviders = new List<IDiscountAmountProvider> { new DiscountAmountProviderTests() };
_dicountService = new DiscountService(_cacheBase, _repository, _discountCouponRepository, _discountUsageHistoryRepository,
- _workContextMock.Object, _discountProviders, _discountAmountProviders, _mediatorMock.Object);
+ _workContextMock.Object, _discountProviders, _discountAmountProviders, _mediatorMock.Object, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
index be5363c39..31aa0c14e 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
@@ -56,7 +56,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
+ _brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AccessControlConfig());
_brandImportDataObject = new BrandImportDataObject(_brandService, _pictureServiceMock.Object, _brandLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
index 595ef965a..70baee75e 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
@@ -57,7 +57,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _categoryService = new CategoryService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
+ _categoryService = new CategoryService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService(new AccessControlConfig()), new AccessControlConfig());
_categoryImportDataObject = new CategoryImportDataObject(_categoryService, _pictureServiceMock.Object, _categoryLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
index 50a1a0269..bdd9183fc 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
@@ -57,7 +57,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _collectionService = new CollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
+ _collectionService = new CollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService(new AccessControlConfig()), new AccessControlConfig());
_collectionImportDataObject = new CollectionImportDataObject(_collectionService, _pictureServiceMock.Object, _collectionLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
index 9d49394de..48a73c7db 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
@@ -82,7 +82,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _productService = new ProductService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
+ _productService = new ProductService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService(new AccessControlConfig()));
_productImportDataObject = new ProductImportDataObject
(_productService, _pictureServiceMock.Object, _productLayoutServiceMock.Object, _deliveryDateServiceMock.Object,
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeFormatterTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeFormatterTests.cs
index 7045ab174..a6a7fd2ff 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeFormatterTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeFormatterTests.cs
@@ -9,6 +9,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Infrastructure;
+using Grand.Infrastructure.Configuration;
using Grand.SharedKernel.Extensions;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -47,7 +48,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_pricingServiceMock = new Mock<IPricingService>();
_productServiceMock = new Mock<IProductService>();
_mediatorMock = new Mock<IMediator>();
- _aclServiceMock = new AclService();
+ _aclServiceMock = new AclService(new AccessControlConfig());
_productAttributeFormatter = new ProductAttributeFormatter(_workContextMock.Object, _productAttributeServiceMock.Object,
_taxServiceMock.Object, _priceFormatterMock.Object, _pricingServiceMock.Object, _productServiceMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
index 715827c78..97371beb3 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
@@ -42,7 +42,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_mediatorMock.Setup(x => x.Send(It.IsAny<GetProductArchByIdQuery>(), default))
.Returns(Task.FromResult(new Product()));
- _aclServiceMock = new AclService();
+ _aclServiceMock = new AclService(new AccessControlConfig());
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productService = new ProductService(_cacheBase, _productRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs
index df091fa81..8808b58a8 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/StockQuantityServiceTests.cs
@@ -1,10 +1,8 @@
using Grand.Business.Catalog.Services.Products;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
namespace Grand.Business.Catalog.Tests.Services.Products
{
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
index e8ded521d..7ff16ee24 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
@@ -8,6 +8,7 @@ using Grand.Domain.Localization;
using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.SharedKernel.Extensions;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -120,7 +121,7 @@ namespace Grand.Business.Checkout.Tests.Services.CheckoutAttributes
_workContextMock = new Mock<IWorkContext>();
_checkoutAttributeService = new CheckoutAttributeService(cacheManager.Object, _checkoutAttributeRepo,
- _eventPublisher, _workContextMock.Object);
+ _eventPublisher, _workContextMock.Object, new AccessControlConfig());
_checkoutAttributeParser = new CheckoutAttributeParser(_checkoutAttributeService);
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeServiceTests.cs
index 670326f59..d29ab6da8 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Data;
using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Checkout.Tests.Services.CheckoutAttributes
_repositoryMock = new Mock<IRepository<CheckoutAttribute>>();
_mediatorMock = new Mock<IMediator>();
_workContextMock = new Mock<IWorkContext>();
- _service = new CheckoutAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object, _workContextMock.Object);
+ _service = new CheckoutAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object, _workContextMock.Object, new AccessControlConfig());
}
[TestMethod]
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
index fd8f5faeb..923be536e 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
@@ -1,7 +1,6 @@
using Grand.Business.Checkout.Services.Orders;
using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Data.Tests.MongoDb;
-using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Orders;
using Grand.Infrastructure.Caching;
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Validators/ShoppingCartValidatorsTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Validators/ShoppingCartValidatorsTests.cs
index 86bfbab8d..b79f4f4b8 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Validators/ShoppingCartValidatorsTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Validators/ShoppingCartValidatorsTests.cs
@@ -12,11 +12,6 @@ using Grand.Domain.Orders;
using Grand.Domain.Permissions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Grand.Business.Checkout.Tests.Validators
{
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/BlogServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/BlogServiceTests.cs
index 9d69c42ca..3cc628058 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/BlogServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/BlogServiceTests.cs
@@ -2,6 +2,7 @@
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -30,7 +31,7 @@ namespace Grand.Business.Cms.Tests.Services
_mediatorMock = new Mock<IMediator>();
_settings = new CatalogSettings();
_blogService = new BlogService(_blogPostRepositoryMock.Object, _blogCommentRepositoryMock.Object,
- _blogCategoryRepositoryMock.Object, _blogProductRepositoryMock.Object, _mediatorMock.Object);
+ _blogCategoryRepositoryMock.Object, _blogProductRepositoryMock.Object, _mediatorMock.Object, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
index 5ce8806f8..7df40188b 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
@@ -41,7 +41,7 @@ namespace Grand.Business.Cms.Tests.Services
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_knowledgebaseService = new KnowledgebaseService(_repositoryKnowledgebaseCategory, _repositoryKnowledgebaseArticle, _repositoryKnowledgebaseArticleComment, _mediatorMock.Object,
- _workContextMock.Object, _cacheBase);
+ _workContextMock.Object, _cacheBase, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs
index 44f839cf8..692f275a0 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/NewsServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Domain.News;
using Grand.Infrastructure;
+using Grand.Infrastructure.Configuration;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
@@ -30,7 +31,7 @@ namespace Grand.Business.Cms.Tests.Services
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "", Name = "test store" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
- _newsService = new NewsService(_repository, _mediatorMock.Object, _workContextMock.Object);
+ _newsService = new NewsService(_repository, _mediatorMock.Object, _workContextMock.Object, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
index b507b712f..eca4302a1 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
@@ -36,12 +36,12 @@ namespace Grand.Business.Cms.Tests.Services
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _aclService = new AclService();
+ _aclService = new AclService(new AccessControlConfig());
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "", Name = "test store" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
- _pageService = new PageService(_repository, _workContextMock.Object, _aclService, _mediatorMock.Object, _cacheBase);
+ _pageService = new PageService(_repository, _workContextMock.Object, _aclService, _mediatorMock.Object, _cacheBase, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
index c113af82b..723db9706 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
@@ -26,7 +26,7 @@ namespace Grand.Business.Common.Tests.Services.Directory
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase);
+ _countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase, new AccessControlConfig());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
index 370d2fab7..b8aebecb2 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
@@ -31,7 +31,8 @@ namespace Grand.Business.Common.Tests.Services.ExportImport
_mediatorMock = new Mock<IMediator>();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase);
+ var accessControlConfig = new AccessControlConfig();
+ _countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase, accessControlConfig);
_countryImportDataObject = new CountryImportDataObject(_countryService);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs b/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs
index b2dd1c654..a58a8b835 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs
@@ -1,6 +1,6 @@
using Grand.Business.Common.Services.Security;
using Grand.Domain.Catalog;
-using Grand.SharedKernel.Extensions;
+using Grand.Infrastructure.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Grand.Business.Common.Tests.Services.Security
@@ -10,12 +10,13 @@ namespace Grand.Business.Common.Tests.Services.Security
{
private CatalogSettings _settings;
private AclService _aclService;
-
+ private AccessControlConfig _accessControlConfig;
[TestInitialize]
public void Init()
{
_settings = new CatalogSettings();
- _aclService = new AclService();
+ _accessControlConfig = new AccessControlConfig();
+ _aclService = new AclService(_accessControlConfig);
}
[TestMethod]
@@ -35,7 +36,7 @@ namespace Grand.Business.Common.Tests.Services.Security
product.LimitedToStores = false;
Assert.IsTrue(_aclService.Authorize(product, "id"));
Assert.IsTrue(_aclService.Authorize(product, ""));
- CommonHelper.IgnoreStoreLimitations = true;
+ _accessControlConfig.IgnoreStoreLimitations = true;
Assert.IsTrue(_aclService.Authorize(product, "id"));
}
}
diff --git a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs
index 085dc82d0..c4dfa2a8b 100644
--- a/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs
+++ b/src/Tests/Grand.Business.Customers.Tests/Handler/CustomerLoggedInNotificationHandlerTests.cs
@@ -1,11 +1,7 @@
-using Grand.Business.Core.Interfaces.Common.Directory;
-using Grand.Business.Customers.Commands.Handlers;
-using Grand.Business.Core.Commands.Customers;
-using Grand.Business.Core.Events.Customers;
+using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Customers.Events.Handlers;
using Grand.Domain.Customers;
-using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerManagerServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerManagerServiceTests.cs
index 07436deb0..d6b55344b 100644
--- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerManagerServiceTests.cs
+++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerManagerServiceTests.cs
@@ -4,7 +4,6 @@ using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Customers.Services;
using Grand.Domain.Customers;
-using Grand.SharedKernel;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
index 3a7ced7fe..31a350e33 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
@@ -30,9 +30,9 @@ namespace Grand.Business.Marketing.Tests.Services.Contacts
_workContextMock = new Mock<IWorkContext>();
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
-
+ var accessControlConfig = new AccessControlConfig();
_cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
- _contactAttributeService = new ContactAttributeService(_cacheBase, _repository, _mediatorMock.Object, _workContextMock.Object);
+ _contactAttributeService = new ContactAttributeService(_cacheBase, _repository, _mediatorMock.Object, _workContextMock.Object, accessControlConfig);
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CoursesServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CoursesServiceTests.cs
index bb59bcb7f..5d932547e 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CoursesServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Courses/CoursesServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Courses;
using Grand.Domain.Data;
using Grand.Domain.Orders;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -26,7 +27,8 @@ namespace Grand.Business.Marketing.Tests.Services.Courses
_orderRepositoryMock = new Mock<IRepository<Order>>();
_mediatorMock = new Mock<IMediator>();
_settings = new CatalogSettings();
- _courseService = new CourseService(_courseRepositoryMock.Object, _orderRepositoryMock.Object, _mediatorMock.Object);
+ var accessControlConfig = new AccessControlConfig();
+ _courseService = new CourseService(_courseRepositoryMock.Object, _orderRepositoryMock.Object, _mediatorMock.Object, accessControlConfig);
}
diff --git a/src/Tests/Grand.Business.Messages.Tests/Commands/InsertContactUsCommandHandlerTests.cs b/src/Tests/Grand.Business.Messages.Tests/Commands/InsertContactUsCommandHandlerTests.cs
index 7c73cb871..c446384a0 100644
--- a/src/Tests/Grand.Business.Messages.Tests/Commands/InsertContactUsCommandHandlerTests.cs
+++ b/src/Tests/Grand.Business.Messages.Tests/Commands/InsertContactUsCommandHandlerTests.cs
@@ -1,6 +1,4 @@
-using Grand.Business.Messages.Commands.Handlers;
-using Grand.Business.Core.Commands.Messages;
-using Grand.Business.Core.Commands.Messages.Common;
+using Grand.Business.Core.Commands.Messages.Common;
using Grand.Business.Messages.Commands.Handlers.Common;
using Grand.Domain.Common;
using Grand.Domain.Data;
diff --git a/src/Tests/Grand.Business.Messages.Tests/Services/MessageTemplateServiceTests.cs b/src/Tests/Grand.Business.Messages.Tests/Services/MessageTemplateServiceTests.cs
index 67e12ac3e..5727b9708 100644
--- a/src/Tests/Grand.Business.Messages.Tests/Services/MessageTemplateServiceTests.cs
+++ b/src/Tests/Grand.Business.Messages.Tests/Services/MessageTemplateServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -29,7 +30,8 @@ namespace Grand.Business.Messages.Tests.Services
_repositoryMock = new Mock<IRepository<MessageTemplate>>();
_mediatorMock = new Mock<IMediator>();
_settings = new CatalogSettings();
- _service = new MessageTemplateService(_cacheMock.Object, _aclService.Object, _repositoryMock.Object, _mediatorMock.Object);
+ var accessControlConfig = new AccessControlConfig();
+ _service = new MessageTemplateService(_cacheMock.Object, _aclService.Object, _repositoryMock.Object, _mediatorMock.Object, accessControlConfig);
}
[TestMethod]
diff --git a/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs b/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs
index 2036cac36..489f36f09 100644
--- a/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs
+++ b/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs
@@ -3,7 +3,6 @@ using Grand.Business.Core.Interfaces.Messages;
using Grand.Business.System.Services.BackgroundServices.ScheduleTasks;
using Grand.Domain;
using Grand.Domain.Customers;
-using Grand.Domain.Logging;
using Grand.Domain.Messages;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
diff --git a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
index a46305364..9a98b9c6b 100644
--- a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
@@ -1,6 +1,5 @@
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Configuration;
-using Grand.SharedKernel.Extensions;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/CustomerGroups.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/CustomerGroups.cshtml
index 01f493f0d..b12a93794 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/CustomerGroups.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/CustomerGroups.cshtml
@@ -1,4 +1,5 @@
@model string[]
+@inject Grand.Infrastructure.Configuration.AccessControlConfig AccessControlConfig;
@{
var warnings = true;
if (ViewData["DisableIgnoreAclWarnings"] != null)
@@ -7,7 +8,7 @@
}
}
@Html.ListBoxFor(model => model, new List<SelectListItem>())
-@if (CommonHelper.IgnoreAcl && warnings)
+@if (AccessControlConfig.IgnoreAcl && warnings)
{
<div class="note note-info">@Loc["Admin.System.Warnings.IgnoreAcl"]</div>
}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Stores.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Stores.cshtml
index b00437f1d..39caf21bc 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Stores.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Stores.cshtml
@@ -1,4 +1,6 @@
-@model string[]
+@using Grand.Infrastructure.Configuration
+@model string[]
+@inject AccessControlConfig AccessControlConfig
@{
var warnings = true;
if (ViewData["DisableIgnoreStoreWarnings"] != null)
@@ -8,7 +10,7 @@
}
@Html.ListBoxFor(model => model, new List<SelectListItem>())
-@if (CommonHelper.IgnoreStoreLimitations && warnings)
+@if (AccessControlConfig.IgnoreStoreLimitations && warnings)
{
<div class="note note-info">@Loc["Admin.System.Warnings.IgnoreStoreLimitations"]</div>
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
index 86154b87c..d7c8edc79 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
@@ -12,7 +12,6 @@ using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Roslyn;
-using Grand.SharedKernel.Extensions;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Common;
using Grand.Web.Common.DataSource;
@@ -44,6 +43,8 @@ namespace Grand.Web.Admin.Controllers
private readonly CurrencySettings _currencySettings;
private readonly MeasureSettings _measureSettings;
private readonly ExtensionsConfig _extConfig;
+ private readonly AccessControlConfig _accessControlConfig;
+
#endregion
#region Constructors
@@ -61,7 +62,7 @@ namespace Grand.Web.Admin.Controllers
ILogger logger,
CurrencySettings currencySettings,
MeasureSettings measureSettings,
- ExtensionsConfig extConfig)
+ ExtensionsConfig extConfig, AccessControlConfig accessControlConfig)
{
_paymentService = paymentService;
_shippingService = shippingService;
@@ -76,6 +77,7 @@ namespace Grand.Web.Admin.Controllers
_webHostEnvironment = webHostEnvironment;
_logger = logger;
_extConfig = extConfig;
+ _accessControlConfig = accessControlConfig;
_machineNameProvider = machineNameProvider;
}
@@ -256,14 +258,14 @@ namespace Grand.Web.Admin.Controllers
});
//performance settings
- if (CommonHelper.IgnoreStoreLimitations)
+ if (_accessControlConfig.IgnoreStoreLimitations)
{
model.SystemWarnings.Add(new SystemInfoModel.SystemWarningModel {
Level = SystemInfoModel.SystemWarningModel.SystemWarningLevel.Warning,
Text = _translationService.GetResource("Admin.System.Warnings.Performance.IgnoreStoreLimitations")
});
}
- if (CommonHelper.IgnoreAcl)
+ if (_accessControlConfig.IgnoreAcl)
{
model.SystemWarnings.Add(new SystemInfoModel.SystemWarningModel {
Level = SystemInfoModel.SystemWarningModel.SystemWarningLevel.Warning,
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 1939930c4..b2d6b9562 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -116,7 +116,13 @@
//separator comma
"InstalledPlugins": ""
},
+ "AccessControl": {
+ /// A value indicating whether to ignore ACL rules
+ "IgnoreAcl": false,
+ //A value indicating whether to ignore "limit per store" rules
+ "IgnoreStoreLimitations": false
+ },
"Performance": {
//Flag for whether to enable html minification
@@ -127,12 +133,6 @@
//You may want to disable it, for example, If you have an active IIS Dynamic Compression Module configured at the server level
"UseResponseCompression": false,
- /// A value indicating whether to ignore ACL rules
- "IgnoreAcl": false,
-
- //A value indicating whether to ignore "limit per store" rules
- "IgnoreStoreLimitations": false,
-
//Gets or sets a value indicating whether mini profiler should be displayed in public store (used for debugging)
"DisplayMiniProfilerInPublicStore": false,
diff --git a/src/Web/Grand.Web/Commands/Models/Customers/SubAccountAddCommand.cs b/src/Web/Grand.Web/Commands/Models/Customers/SubAccountAddCommand.cs
index b61aaedcb..61239149a 100644
--- a/src/Web/Grand.Web/Commands/Models/Customers/SubAccountAddCommand.cs
+++ b/src/Web/Grand.Web/Commands/Models/Customers/SubAccountAddCommand.cs
@@ -1,5 +1,4 @@
-using Grand.Business.Core.Utilities.Customers;
-using Grand.Domain.Customers;
+using Grand.Domain.Customers;
using Grand.Domain.Stores;
using Grand.Web.Models.Customer;
using MediatR;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
index dc2810b77..0b9175c7f 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
@@ -6,7 +6,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Infrastructure.Caching;
-using Grand.SharedKernel.Extensions;
+using Grand.Infrastructure.Configuration;
using Grand.Web.Events.Cache;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
@@ -23,7 +23,8 @@ namespace Grand.Web.Features.Handlers.Catalog
private readonly IMediator _mediator;
private readonly MediaSettings _mediaSettings;
private readonly CatalogSettings _catalogSettings;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
public GetCategorySimpleHandler(
ICacheBase cacheBase,
ICategoryService categoryService,
@@ -31,7 +32,8 @@ namespace Grand.Web.Features.Handlers.Catalog
IProductService productService,
IMediator mediator,
MediaSettings mediaSettings,
- CatalogSettings catalogSettings)
+ CatalogSettings catalogSettings,
+ AccessControlConfig accessControlConfig)
{
_cacheBase = cacheBase;
_categoryService = categoryService;
@@ -40,6 +42,7 @@ namespace Grand.Web.Features.Handlers.Catalog
_mediator = mediator;
_mediaSettings = mediaSettings;
_catalogSettings = catalogSettings;
+ _accessControlConfig = accessControlConfig;
}
public async Task<IList<CategorySimpleModel>> Handle(GetCategorySimple request, CancellationToken cancellationToken)
@@ -115,7 +118,7 @@ namespace Grand.Web.Features.Handlers.Catalog
//include subcategories
if (_catalogSettings.ShowCategoryProductNumberIncludingSubcategories)
categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds { Customer = request.Customer, Store = request.Store, ParentCategoryId = category.Id }));
- categoryModel.NumberOfProducts = _productService.GetCategoryProductNumber(request.Customer, categoryIds, request.Store.Id, CommonHelper.IgnoreAcl, CommonHelper.IgnoreStoreLimitations);
+ categoryModel.NumberOfProducts = _productService.GetCategoryProductNumber(request.Customer, categoryIds, request.Store.Id, _accessControlConfig.IgnoreAcl, _accessControlConfig.IgnoreStoreLimitations);
}
if (loadSubCategories)
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
index 91e61f946..72ef3c565 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
@@ -14,7 +14,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Media;
using Grand.Infrastructure;
-using Grand.SharedKernel.Extensions;
+using Grand.Infrastructure.Configuration;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
@@ -39,7 +39,8 @@ namespace Grand.Web.Features.Handlers.Catalog
private readonly CatalogSettings _catalogSettings;
private readonly MediaSettings _mediaSettings;
private readonly BlogSettings _blogSettings;
-
+ private readonly AccessControlConfig _accessControlConfig;
+
public GetSearchAutoCompleteHandler(
IPictureService pictureService,
IBrandService brandService,
@@ -55,7 +56,7 @@ namespace Grand.Web.Features.Handlers.Catalog
IPermissionService permissionService,
CatalogSettings catalogSettings,
MediaSettings mediaSettings,
- BlogSettings blogSettings)
+ BlogSettings blogSettings, AccessControlConfig accessControlConfig)
{
_pictureService = pictureService;
_brandService = brandService;
@@ -72,6 +73,7 @@ namespace Grand.Web.Features.Handlers.Catalog
_catalogSettings = catalogSettings;
_mediaSettings = mediaSettings;
_blogSettings = blogSettings;
+ _accessControlConfig = accessControlConfig;
}
public async Task<IList<SearchAutoCompleteModel>> Handle(GetSearchAutoComplete request, CancellationToken cancellationToken)
@@ -147,10 +149,10 @@ namespace Grand.Web.Features.Handlers.Catalog
var brand = await _brandService.GetBrandById(item);
if (brand is not { Published: true }) continue;
var allow = true;
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
if (!_aclService.Authorize(brand, _workContext.CurrentCustomer))
allow = false;
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
if (!_aclService.Authorize(brand, storeId))
allow = false;
if (!allow) continue;
@@ -171,10 +173,10 @@ namespace Grand.Web.Features.Handlers.Catalog
var category = await _categoryService.GetCategoryById(item);
if (category is not { Published: true }) continue;
var allow = true;
- if (!CommonHelper.IgnoreAcl)
+ if (!_accessControlConfig.IgnoreAcl)
if (!_aclService.Authorize(category, _workContext.CurrentCustomer))
allow = false;
- if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_accessControlConfig.IgnoreStoreLimitations)
if (!_aclService.Authorize(category, storeId))
allow = false;
if (!allow) continue;