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.

Allow rendering only one Captcha on the vendor page

KrzysztofPajakfd5b0831582e
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
index 236a52e9f..800b3b7e5 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
@@ -7,6 +7,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Media;
using Grand.Domain.Vendors;
using Grand.Infrastructure.Caching;
+using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Common;
using Grand.Web.Features.Models.Products;
@@ -34,6 +35,7 @@ namespace Grand.Web.Features.Handlers.Catalog
private readonly VendorSettings _vendorSettings;
private readonly MediaSettings _mediaSettings;
private readonly CatalogSettings _catalogSettings;
+ private readonly CaptchaSettings _captchaSettings;
public GetVendorHandler(
IMediator mediator,
@@ -44,7 +46,8 @@ namespace Grand.Web.Features.Handlers.Catalog
ISpecificationAttributeService specificationAttributeService,
IHttpContextAccessor httpContextAccessor,
ICacheBase cacheBase,
- CatalogSettings catalogSettings)
+ CatalogSettings catalogSettings,
+ CaptchaSettings captchaSettings)
{
_mediator = mediator;
_pictureService = pictureService;
@@ -55,6 +58,7 @@ namespace Grand.Web.Features.Handlers.Catalog
_httpContextAccessor = httpContextAccessor;
_cacheBase = cacheBase;
_catalogSettings = catalogSettings;
+ _captchaSettings = captchaSettings;
}
public async Task<VendorModel> Handle(GetVendor request, CancellationToken cancellationToken)
@@ -68,6 +72,7 @@ namespace Grand.Web.Features.Handlers.Catalog
MetaTitle = request.Vendor.GetTranslation(x => x.MetaTitle, request.Language.Id),
SeName = request.Vendor.GetSeName(request.Language.Id),
AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
+ RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnVendorReviewPage || _captchaSettings.ShowOnContactUsPage)
UserFields = request.Vendor.UserFields
};
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
index 119019851..50f62633f 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
@@ -21,6 +21,7 @@ namespace Grand.Web.Models.Catalog
public string MetaTitle { get; set; }
public string SeName { get; set; }
public bool AllowCustomersToContactVendors { get; set; }
+ public bool RenderCaptcha { get; set; }
public VendorAddressModel Address { get; set; }
public PictureModel PictureModel { get; set; }
public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
diff --git a/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml b/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
index b69ed992e..d7e9796d1 100644
--- a/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
@@ -178,7 +178,14 @@
</template>
</div>
</div>
-
+@if(Model.RenderCaptcha)
+{
+ <div id="captcha-container">
+ <div class="captcha-box" id="captcha-box">
+ <captcha />
+ </div>
+ </div>
+}
@await Component.InvokeAsync("Widget", new { widgetZone = "vendordetails_bottom", additionalData = Model.Id })
@section filters