Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Collapse store Url/SecureUrl/SslEnabled onto a single Url (#834)
Krzysztof Pajak20851fd5356b
diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidBlogComment.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidBlogComment.csindex 0cdea9ca0..b75e12d9f 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidBlogComment.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidBlogComment.cs@@ -24,7 +24,7 @@ public class LiquidBlogComment : Drop_host = host;_language = language;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidCustomer.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidCustomer.csindex b9e028985..2defeb428 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidCustomer.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidCustomer.cs@@ -22,7 +22,7 @@ public class LiquidCustomer : Drop_customerNote = customerNote;_store = store;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidKnowledgebase.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidKnowledgebase.csindex 095a66e93..57e69abed 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidKnowledgebase.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidKnowledgebase.cs@@ -24,7 +24,7 @@ public class LiquidKnowledgebase : Drop_host = host;_language = language;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidMerchandiseReturn.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidMerchandiseReturn.csindex 7be28aa7c..3c15c40e8 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidMerchandiseReturn.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidMerchandiseReturn.cs@@ -25,7 +25,7 @@ public class LiquidMerchandiseReturn : Drop_host = host;_merchandiseReturnNote = merchandiseReturnNote;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');Items = new List<LiquidMerchandiseReturnItem>();AdditionalTokens = new Dictionary<string, string>();diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsComment.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsComment.csindex eea16d705..3b41433e1 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsComment.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsComment.cs@@ -24,7 +24,7 @@ public class LiquidNewsComment : Drop_language = language;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsLetterSubscription.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsLetterSubscription.csindex 509cd034f..10b5666f8 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsLetterSubscription.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidNewsLetterSubscription.cs@@ -18,7 +18,7 @@ public class LiquidNewsLetterSubscription : Drop_store = store;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrder.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrder.csindex 4e4f0d103..08f7fe076 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrder.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrder.cs@@ -35,7 +35,7 @@ public class LiquidOrder : Drop_vendor = vendor;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');OrderItems = new List<LiquidOrderItem>();diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrderItem.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrderItem.csindex 8cc9d365e..9b11dbd16 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrderItem.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOrderItem.cs@@ -30,7 +30,7 @@ public class LiquidOrderItem : Drop_vendor = vendor;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOutOfStockSubscription.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOutOfStockSubscription.csindex deb4f82e6..db33a9bd6 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOutOfStockSubscription.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidOutOfStockSubscription.cs@@ -23,7 +23,7 @@ public class LiquidOutOfStockSubscription : Drop_language = language;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidProduct.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidProduct.csindex bfc6fc8c8..45ff0fedf 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidProduct.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidProduct.cs@@ -20,7 +20,7 @@ public class LiquidProduct : Drop_language = language;_store = store;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');AdditionalTokens = new Dictionary<string, string>();}diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidShipment.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidShipment.csindex ffb36fe65..12478f83f 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidShipment.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidShipment.cs@@ -23,7 +23,7 @@ public class LiquidShipment : Drop_store = store;_order = order;_host = host;- url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));+ url = _host?.Url.Trim('/') ?? _store.Url.Trim('/');ShipmentItems = new List<LiquidShipmentItem>();AdditionalTokens = new Dictionary<string, string>();diff --git a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidStore.cs b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidStore.csindex ab0b58356..6dfee08c8 100644--- a/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidStore.cs+++ b/src/Business/Grand.Business.Core/Utilities/Messages/DotLiquidDrops/LiquidStore.cs@@ -24,7 +24,7 @@ public class LiquidStore : Droppublic string Shortcut => _store.Shortcut;- public string URL => _store.SslEnabled ? _store.SecureUrl : _store.Url;+ public string URL => _store.Url;public string Email => _emailAccount.Email;diff --git a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.csindex b521710f5..1a32101a0 100644--- a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs+++ b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs@@ -106,7 +106,7 @@ public class GetSitemapXmlCommandHandler : IRequestHandler<GetSitemapXmlCommand,/// <returns>Protocol name as string</returns>private string GetHttpProtocol(){- return _request.Store.SslEnabled ? "https" : "http";+ return GetStoreUri().Scheme;}/// <summary>@@ -115,9 +115,7 @@ public class GetSitemapXmlCommandHandler : IRequestHandler<GetSitemapXmlCommand,/// <returns>Protocol name as string</returns>private HostString GetHost(){- return _request.Store.SslEnabled- ? new HostString(_request.Store.SecureUrl.Replace("https://", "").Trim('/'))- : new HostString(_request.Store.Url.Replace("http://", "").Trim('/'));+ return new HostString(GetStoreUri().Authority);}/// <summary>@@ -126,7 +124,12 @@ public class GetSitemapXmlCommandHandler : IRequestHandler<GetSitemapXmlCommand,/// <returns>Store url</returns>private string GetStoreLocation(){- return _request.Store.SslEnabled ? _request.Store.SecureUrl : _request.Store.Url;+ return _request.Store.Url;+ }++ private Uri GetStoreUri()+ {+ return new Uri(_request.Store.Url);}private async Task<IList<SitemapUrl>> GenerateUrls(Language language, Store store)diff --git a/src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetShoppingCartTokensCommandHandler.cs b/src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetShoppingCartTokensCommandHandler.csindex 0edac22ad..2b1e0827d 100644--- a/src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetShoppingCartTokensCommandHandler.cs+++ b/src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetShoppingCartTokensCommandHandler.cs@@ -41,7 +41,7 @@ public class GetShoppingCartTokensCommandHandler : IRequestHandler<GetShoppingCaproduct.ProductPictures.OrderByDescending(p => p.IsDefault).ThenBy(p => p.DisplayOrder).FirstOrDefault()?.PictureId, 100,- storeLocation: request.Store.SslEnabled ? request.Store.SecureUrl : request.Store.Url);+ storeLocation: request.Store.Url);//attributesif (item.Attributes != null && item.Attributes.Any())diff --git a/src/Core/Grand.Domain/Stores/Store.cs b/src/Core/Grand.Domain/Stores/Store.csindex f1cb7a661..95b18b003 100644--- a/src/Core/Grand.Domain/Stores/Store.cs+++ b/src/Core/Grand.Domain/Stores/Store.cs@@ -18,20 +18,10 @@ public class Store : BaseEntity, ITranslationEntitypublic string Shortcut { get; set; }/// <summary>- /// Gets or sets the store URL+ /// Gets or sets the store URL, including the scheme/// </summary>public string Url { get; set; }- /// <summary>- /// Gets or sets a value indicating whether SSL is enabled- /// </summary>- public bool SslEnabled { get; set; }-- /// <summary>- /// Gets or sets the store secure URL (HTTPS)- /// </summary>- public string SecureUrl { get; set; }-/// <summary>/// Gets or sets the list of domains/// </summary>diff --git a/src/Modules/Grand.Module.Api/DTOs/Common/StoreDto.cs b/src/Modules/Grand.Module.Api/DTOs/Common/StoreDto.csindex 491f7031b..e939ccc4b 100644--- a/src/Modules/Grand.Module.Api/DTOs/Common/StoreDto.cs+++ b/src/Modules/Grand.Module.Api/DTOs/Common/StoreDto.cs@@ -6,8 +6,6 @@ public class StoreDto : BaseApiEntityModel{public string Name { get; set; }public string Url { get; set; }- public bool SslEnabled { get; set; }- public string SecureUrl { get; set; }public string Hosts { get; set; }public string DefaultLanguageId { get; set; }public string DefaultWarehouseId { get; set; }diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataRobotsTxt.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataRobotsTxt.csindex 75c76cdaf..3f615d11f 100644--- a/src/Modules/Grand.Module.Installer/Services/InstallDataRobotsTxt.cs+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataRobotsTxt.cs@@ -8,7 +8,7 @@ public partial class InstallationServiceprotected virtual async Task InstallDataRobotsTxt(Store store){- var url = store.SslEnabled ? store.SecureUrl : store.Url;+ var url = store.Url;var robotsTxt = new RobotsTxt {Name = "RobotsTXT",diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataStores.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataStores.csindex 790308394..2e047e9df 100644--- a/src/Modules/Grand.Module.Installer/Services/InstallDataStores.cs+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataStores.cs@@ -13,9 +13,7 @@ public partial class InstallationServicenew Store {Name = "Your store name",Shortcut = "Store",- Url = $"http://{host}/",- SecureUrl = $"https://{host}/",- SslEnabled = httpscheme.ToLowerInvariant() == "https",+ Url = $"{httpscheme}://{host}/",DisplayOrder = 1,CompanyName = companyName,CompanyAddress = companyAddress,diff --git a/src/Modules/Grand.Module.Migration/Migrations/1.1/MigrationUpdateStore.cs b/src/Modules/Grand.Module.Migration/Migrations/1.1/MigrationUpdateStore.csindex 6c9e5cddb..b14160800 100644--- a/src/Modules/Grand.Module.Migration/Migrations/1.1/MigrationUpdateStore.cs+++ b/src/Modules/Grand.Module.Migration/Migrations/1.1/MigrationUpdateStore.cs@@ -29,10 +29,9 @@ public class MigrationUpdateStore : IMigrationif (!store.Domains.Any()){var storeUri = new Uri(store.Url);- var httpscheme = store.SslEnabled ? "https" : "http";var domain = new DomainHost {HostName = storeUri.Authority,- Url = $"{httpscheme}://{storeUri.Authority}",+ Url = $"{storeUri.Scheme}://{storeUri.Authority}",Primary = true};store.Domains.Add(domain);diff --git a/src/Modules/Grand.Module.Migration/Migrations/2.4/MigrationStoreSingleUrl.cs b/src/Modules/Grand.Module.Migration/Migrations/2.4/MigrationStoreSingleUrl.csnew file mode 100644index 000000000..4f8a586b3--- /dev/null+++ b/src/Modules/Grand.Module.Migration/Migrations/2.4/MigrationStoreSingleUrl.cs@@ -0,0 +1,75 @@+using Grand.Data;+using Grand.Domain.Stores;+using Grand.Infrastructure.Migrations;+using Microsoft.Extensions.DependencyInjection;+using Microsoft.Extensions.Logging;++namespace Grand.Module.Migration.Migrations._2._4;++/// <summary>+/// Collapses the store address onto a single <see cref="Store.Url" />. Until 2.4 a store carried+/// <c>Url</c>, <c>SecureUrl</c> and <c>SslEnabled</c>, and every consumer resolved the effective+/// address as <c>SslEnabled ? SecureUrl : Url</c>. Both extra fields are gone - <c>Url</c> now holds+/// the full address including the scheme, and forcing HTTPS belongs to the host (UseHttpsRedirection,+/// UseHsts, the reverse proxy), not to the store record.+/// The effective address of an existing installation is already stored on the primary+/// <see cref="DomainHost" />: the installer, the admin store editor and the 1.1 domains migration all+/// wrote exactly that resolved value there. This copies it back onto <c>Url</c>, so a store that ran on+/// HTTPS keeps generating HTTPS links in emails, sitemap.xml and robots.txt.+/// The now unmapped <c>SslEnabled</c> and <c>SecureUrl</c> elements are left in the documents - the+/// global IgnoreExtraElementsConvention skips them on read, and they disappear the next time the store+/// is saved.+/// </summary>+public class MigrationStoreSingleUrl : IMigration+{+ public int Priority => 1;+ public DbVersion Version => new(2, 4);+ public Guid Identity => new("9E3C7A21-08B4-4F6D-B5A2-7D14C6E39F80");+ public string Name => "Collapse store Url/SecureUrl/SslEnabled onto a single Url 2.4";++ /// <summary>+ /// Upgrade process+ /// </summary>+ /// <param name="serviceProvider"></param>+ /// <returns></returns>+ public bool UpgradeProcess(IServiceProvider serviceProvider)+ {+ var repository = serviceProvider.GetRequiredService<IRepository<Store>>();+ var logService = serviceProvider.GetRequiredService<ILogger<MigrationStoreSingleUrl>>();++ try+ {+ foreach (var store in repository.Table.ToList())+ {+ var effectiveUrl = store.Domains?.FirstOrDefault(x => x.Primary)?.Url;+ if (string.IsNullOrWhiteSpace(effectiveUrl) ||+ !Uri.TryCreate(effectiveUrl.Trim(), UriKind.Absolute, out _))+ {+ //nothing reliable to fall back to - the store keeps whatever Url it had+ logService.LogWarning(+ "Store {StoreName} has no usable primary domain - its Url was left as {StoreUrl}. Verify it in the admin area, it is used to build links in emails and sitemap.xml",+ store.Name, store.Url);+ continue;+ }++ //the 1.1 domains migration wrote the primary domain without a trailing slash, while the store+ //url is concatenated with relative paths (robots.txt, sitemap.xml)+ effectiveUrl = effectiveUrl.Trim();+ if (!effectiveUrl.EndsWith("/"))+ effectiveUrl += "/";++ if (effectiveUrl == store.Url)+ continue;++ store.Url = effectiveUrl;+ repository.Update(store);+ }+ }+ catch (Exception ex)+ {+ logService.LogError(ex, "UpgradeProcess - MigrationStoreSingleUrl (2.4)");+ }++ return true;+ }+}diff --git a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.StoreModel_ToDomain.verified.txt b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.StoreModel_ToDomain.verified.txtindex 28ae0fd58..f4836ab06 100644--- a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.StoreModel_ToDomain.verified.txt+++ b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.StoreModel_ToDomain.verified.txt@@ -1,7 +1,6 @@{Name: Grand Store,Url: https://grandstore.com,- SslEnabled: true,DefaultLanguageId: lang-001,DisplayOrder: 1,CompanyName: Grand LLC,diff --git a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.Store_ToModel.verified.txt b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.Store_ToModel.verified.txtindex 37baa2633..b43b3257c 100644--- a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.Store_ToModel.verified.txt+++ b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.Store_ToModel.verified.txt@@ -1,7 +1,6 @@{Name: Grand Store,Url: https://grandstore.com,- SslEnabled: true,DisplayOrder: 1,CompanyName: Grand LLC,CompanyAddress: 123 Commerce St,diff --git a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.cs b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.csindex 19729d55f..af7fcfc19 100644--- a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.cs+++ b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.cs@@ -341,7 +341,6 @@ public class CommonMappingTests : VerifyBaseId = "store-001",Name = "Grand Store",Url = "https://grandstore.com",- SslEnabled = true,CompanyName = "Grand LLC",CompanyAddress = "123 Commerce St",CompanyPhoneNumber = "+1-555-9999",@@ -362,7 +361,6 @@ public class CommonMappingTests : VerifyBasevar model = new StoreModel {Name = "Grand Store",Url = "https://grandstore.com",- SslEnabled = true,CompanyName = "Grand LLC",DefaultLanguageId = "lang-001",DisplayOrder = 1diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.TabInfo.cshtmlindex e181df810..c19cc9969 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.TabInfo.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.TabInfo.cshtml@@ -48,28 +48,6 @@<span asp-validation-for="Url"></span></div></div>- <div class="form-group">- <admin-label asp-for="SslEnabled"/>- <div class="col-md-9 col-sm-9">- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="SslEnabled"/>- <div class="control__indicator"></div>- </label>- <span asp-validation-for="SslEnabled"></span>- </div>- </div>- <div class="form-group">- <div class="note note-info">- <em>@Loc["Admin.Configuration.Stores.Fields.SslEnabled.Hint2"]</em>- </div>- </div>- <div class="form-group" id="pnlSecureUrl">- <admin-label asp-for="SecureUrl"/>- <div class="col-md-9 col-sm-9">- <admin-input asp-for="SecureUrl"/>- <span asp-validation-for="SecureUrl"></span>- </div>- </div><div class="form-group"><admin-label asp-for="DefaultLanguageId"/><div class="col-md-9 col-sm-9">diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.cshtmlindex d23d6f02f..e690ed9bd 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Store/Partials/CreateOrUpdate.cshtml@@ -1,22 +1,5 @@@model StoreModel-<script>- $(document).ready(function () {-- $("#@Html.IdFor(model => model.SslEnabled)").click(toggleSslEnabled);-- toggleSslEnabled();- });-- function toggleSslEnabled() {- if ($('#@Html.IdFor(model => model.SslEnabled)').is(':checked')) {- $('#pnlSecureUrl').show();- }- else {- $('#pnlSecureUrl').hide();- }- }-</script><vc:admin-widget widget-zone="store_details_top" additional-data="Model"/><div asp-validation-summary="All"></div>diff --git a/src/Web/Grand.Web.AdminShared/Models/Stores/StoreModel.cs b/src/Web/Grand.Web.AdminShared/Models/Stores/StoreModel.csindex aac794658..711fccd98 100644--- a/src/Web/Grand.Web.AdminShared/Models/Stores/StoreModel.cs+++ b/src/Web/Grand.Web.AdminShared/Models/Stores/StoreModel.cs@@ -16,12 +16,6 @@ public class StoreModel : BaseEntityModel, ILocalizedModel<StoreLocalizedModel>[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.Url")]public string Url { get; set; }- [GrandResourceDisplayName("Admin.Configuration.Stores.Fields.SslEnabled")]- public virtual bool SslEnabled { get; set; }-- [GrandResourceDisplayName("Admin.Configuration.Stores.Fields.SecureUrl")]- public virtual string SecureUrl { get; set; }-[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.DisplayOrder")]public int DisplayOrder { get; set; }diff --git a/src/Web/Grand.Web.AdminShared/Services/StoreViewModelService.cs b/src/Web/Grand.Web.AdminShared/Services/StoreViewModelService.csindex f906fea07..73b246303 100644--- a/src/Web/Grand.Web.AdminShared/Services/StoreViewModelService.cs+++ b/src/Web/Grand.Web.AdminShared/Services/StoreViewModelService.cs@@ -114,14 +114,11 @@ public class StoreViewModelService : IStoreViewModelServiceif (!store.Url.Trim().EndsWith("/"))store.Url = store.Url.Trim() + "/";- if (!string.IsNullOrEmpty(store.SecureUrl) && !store.SecureUrl.Trim().EndsWith("/"))- store.SecureUrl = store.SecureUrl.Trim() + "/";-var storeUri = new Uri(store.Url);store.Domains.Add(new DomainHost {HostName = storeUri.Host,- Url = store.SslEnabled ? store.SecureUrl : store.Url,+ Url = store.Url,Primary = true});@@ -136,24 +133,19 @@ public class StoreViewModelService : IStoreViewModelService//ensure we have "/" at the endif (!store.Url.Trim().EndsWith("/"))store.Url = store.Url.Trim() + "/";- if (!string.IsNullOrEmpty(store.SecureUrl) && !store.SecureUrl.Trim().EndsWith("/"))- store.SecureUrl = store.SecureUrl.Trim() + "/";+ var storeUri = new Uri(store.Url);var domain = store.Domains.FirstOrDefault(x => x.Primary);if (domain == null)- {- var storeUri = new Uri(store.Url);store.Domains.Add(new DomainHost {HostName = storeUri.Host,- Url = store.SslEnabled ? store.SecureUrl : store.Url,+ Url = store.Url,Primary = true});- }else{- var storeUri = new Uri(store.Url);domain.HostName = storeUri.Host;- domain.Url = store.SslEnabled ? store.SecureUrl : store.Url;+ domain.Url = store.Url;}await _storeService.UpdateStore(store);diff --git a/src/Web/Grand.Web.AdminShared/Validators/Stores/StoreValidator.cs b/src/Web/Grand.Web.AdminShared/Validators/Stores/StoreValidator.csindex 3d14a7e85..52f462541 100644--- a/src/Web/Grand.Web.AdminShared/Validators/Stores/StoreValidator.cs+++ b/src/Web/Grand.Web.AdminShared/Validators/Stores/StoreValidator.cs@@ -20,38 +20,13 @@ public class StoreValidator : BaseGrandValidator<StoreModel>.WithMessage(translationService.GetResource("Admin.Configuration.Stores.Fields.Url.Required"));RuleFor(x => x.Url).Must((x, _, _) =>{- try- {- var uri = new Uri(x.Url);- return uri != null;- }- catch- {+ //the store url is used to build absolute links outside of a request (emails, sitemap, robots.txt),+ //so it has to be an absolute http(s) url+ if (!Uri.TryCreate(x.Url, UriKind.Absolute, out var uri))return false;- }- }).WithMessage(translationService.GetResource("Admin.Configuration.Stores.Fields.Url.WrongFormat"));- RuleFor(x => x.SecureUrl).Must((x, _, _) =>- {- try- {- if (!x.SslEnabled)- return true;-- var sslUri = new Uri(x.SecureUrl);-- if (!sslUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))- return false;- var storeUri = new Uri(x.Url);- if (sslUri.Host != storeUri.Host)- return false;-- return true;- }- catch- {- return false;- }- }).WithMessage(translationService.GetResource("Admin.Configuration.Stores.Fields.SecureUrl.WrongFormat"));+ return uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) ||+ uri.Scheme.Equals(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase);+ }).WithMessage(translationService.GetResource("Admin.Configuration.Stores.Fields.Url.WrongFormat"));}}\ No newline at end of filediff --git a/src/Web/Grand.Web.Common/StoreContextSetter.cs b/src/Web/Grand.Web.Common/StoreContextSetter.csindex 337ed8f26..93d27dee4 100644--- a/src/Web/Grand.Web.Common/StoreContextSetter.cs+++ b/src/Web/Grand.Web.Common/StoreContextSetter.cs@@ -71,7 +71,7 @@ public class StoreContextSetter : IStoreContextSetterif (store != null)return store.HostValue(host) ?? new DomainHost {Id = int.MinValue.ToString(),- Url = store.SslEnabled ? store.SecureUrl : store.Url,+ Url = store.Url,HostName = "temporary-store"};diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/PdfTemplates/OrderPdfTemplate.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/PdfTemplates/OrderPdfTemplate.cshtmlindex e20589acf..a13dc7180 100644--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/PdfTemplates/OrderPdfTemplate.cshtml+++ b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/PdfTemplates/OrderPdfTemplate.cshtml@@ -126,7 +126,7 @@<h4>@store.CompanyName</h4>if (logoExists){- var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.SslEnabled ? store.SecureUrl : store.Url);+ var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.Url);<div style="float: right; top:10px;"><img src="@url" title="logo" alt="logo"/></div>diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex f460e530f..3fc6e2659 100644Binary files a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml and b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml differdiff --git a/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_240.xml b/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_240.xmlindex 05aa4dab5..719c4b60a 100644--- a/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_240.xml+++ b/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_240.xml@@ -48,4 +48,7 @@<Resource Name="Admin.GiftVouchers.Permissions" Area="Admin"><Value>You can't edit this gift voucher, because it can be used in many stores.</Value></Resource>+ <Resource Name="Admin.Configuration.Stores.Fields.Url.WrongFormat" Area="Admin">+ <Value>Wrong format of the URL - provide the full address including the scheme (e.g. https://yourstore.com/)</Value>+ </Resource></Language>diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex 43ed98a57..e0a36bd6c 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -261,7 +261,7 @@ public class CommonController : BasePublicControllerawait _mediator.Publish(new ChangeStoreEvent(_contextAccessor.WorkContext.CurrentCustomer, selectedstore));if (selectedstore.Url != _contextAccessor.StoreContext.CurrentStore.Url)- return Redirect(selectedstore.SslEnabled ? selectedstore.SecureUrl : selectedstore.Url);+ return Redirect(selectedstore.Url);}}diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.csindex 190fe6370..0b02a83a2 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs@@ -171,12 +171,7 @@ public class GetProductDetailsPageHandler : IRequestHandler<GetProductDetailsPagif (_catalogSettings.ShowShareButton && !string.IsNullOrEmpty(_catalogSettings.PageShareCode)){- var shareCode = _catalogSettings.PageShareCode;- if (store.SslEnabled)- //need to change the add this link to be https linked when the page is, so that the page doesnt ask about mixed mode when viewed in https...- shareCode = shareCode.Replace("http://", "https://");-- model.PageShareCode = shareCode;+ model.PageShareCode = _catalogSettings.PageShareCode;}#endregiondiff --git a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtmlindex 208ff6cc7..f6de98c09 100644--- a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml+++ b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml@@ -126,7 +126,7 @@<h4>@store.CompanyName</h4>if (logoExists){- var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.SslEnabled ? store.SecureUrl : store.Url);+ var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.Url);<div style="float: right; top:10px;"><img src="@url" title="logo" alt="logo"/></div>