Skip to content

Commit

Permalink
Allow rendering only one Captcha on the vendor page
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak committed Nov 3, 2021
1 parent b8e319f commit fd5b083
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class GetVendorHandler : IRequestHandler<GetVendor, VendorModel>
private readonly VendorSettings _vendorSettings;
private readonly MediaSettings _mediaSettings;
private readonly CatalogSettings _catalogSettings;
private readonly CaptchaSettings _captchaSettings;

public GetVendorHandler(
IMediator mediator,
Expand All @@ -44,7 +46,8 @@ public GetVendorHandler(
ISpecificationAttributeService specificationAttributeService,
IHttpContextAccessor httpContextAccessor,
ICacheBase cacheBase,
CatalogSettings catalogSettings)
CatalogSettings catalogSettings,
CaptchaSettings captchaSettings)
{
_mediator = mediator;
_pictureService = pictureService;
Expand All @@ -55,6 +58,7 @@ public GetVendorHandler(
_httpContextAccessor = httpContextAccessor;
_cacheBase = cacheBase;
_catalogSettings = catalogSettings;
_captchaSettings = captchaSettings;
}

public async Task<VendorModel> Handle(GetVendor request, CancellationToken cancellationToken)
Expand All @@ -68,6 +72,7 @@ public async Task<VendorModel> Handle(GetVendor request, CancellationToken cance
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
};

Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web/Models/Catalog/VendorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public VendorModel()
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; }
Expand Down
9 changes: 8 additions & 1 deletion src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd5b083

Please sign in to comment.