Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
V-3060 FIX storefront password handling (#12616)
brozek061d200f73de
diff --git a/admin/app/controllers/spree/admin/storefront_controller.rb b/admin/app/controllers/spree/admin/storefront_controller.rbindex d729159143..2394b2458c 100644--- a/admin/app/controllers/spree/admin/storefront_controller.rb+++ b/admin/app/controllers/spree/admin/storefront_controller.rb@@ -26,7 +26,7 @@ module Spree:meta_description, :meta_title, :meta_keywords, :seo_robots,:facebook, :twitter, :instagram, :linkedin, :youtube, :tiktok, :pinterest,:storefront_custom_code_head, :storefront_custom_code_body_start,- :storefront_custom_code_body_end+ :storefront_custom_code_body_end, :storefront_password)enddiff --git a/admin/app/views/spree/admin/storefront/edit.html.erb b/admin/app/views/spree/admin/storefront/edit.html.erbindex 97f44b3811..3782aad74d 100644--- a/admin/app/views/spree/admin/storefront/edit.html.erb+++ b/admin/app/views/spree/admin/storefront/edit.html.erb@@ -46,21 +46,19 @@<%= Spree.t(:security) %></h5></div>- <div class="card-body">+ <div class="card-body" data-controller="reveal" data-reveal-hidden-class="d-none"><div class="custom-control custom-checkbox mb-2">- <%= f.check_box :preferred_password_protected, class: 'custom-control-input' %>+ <%= f.check_box :preferred_password_protected, class: 'custom-control-input', data: { action: 'reveal#toggle' } %><%= f.label :preferred_password_protected, Spree.t(:password_protected), class: 'custom-control-label' %></div><p class="text-muted small pl-4">Checking this box will put your storefront behind a password.</p>-- <% if @store.prefers_password_protected? %>- <div class="form-group">- <%= f.label :storefront_password, Spree.t(:password) %>- <%= f.text_field :storefront_password, class: 'form-control' %>- </div>- <% end %>++ <div class="form-group <%= @store.prefers_password_protected? ? '' : 'd-none' %>" data-reveal-target="item">+ <%= f.label :storefront_password, Spree.t(:password) %>+ <%= f.text_field :storefront_password, class: 'form-control' %>+ </div></div></div>diff --git a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb b/admin/spec/controllers/spree/admin/storefront_controller_spec.rbindex ef95393ed6..e48e9c76a0 100644--- a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb+++ b/admin/spec/controllers/spree/admin/storefront_controller_spec.rb@@ -23,6 +23,7 @@ describe Spree::Admin::StorefrontController do{name: 'New Store Name',meta_description: 'This is a cool store',+ storefront_password: 'password'}end@@ -33,6 +34,7 @@ describe Spree::Admin::StorefrontController doexpect(store.reload.name).to eq('New Store Name')expect(store.meta_description).to eq('This is a cool store')+ expect(store.storefront_password).to eq('password')endcontext 'when removing assets' dodiff --git a/storefront/spec/features/password_spec.rb b/storefront/spec/features/password_spec.rbnew file mode 100644index 0000000000..4a5a4a6321--- /dev/null+++ b/storefront/spec/features/password_spec.rb@@ -0,0 +1,26 @@+require 'spec_helper'++RSpec.describe 'Password page', type: :feature do+ context 'when storefront is password protected' do+ let(:store) { Spree::Store.default }++ before do+ store.preferred_password_protected = true+ store.storefront_password = 'password'+ store.save!+ end++ it 'redirects to password page' do+ visit spree.root_path+ expect(page).to have_current_path(spree.password_path)+ end++ it 'allows user to provide password and access the store' do+ visit spree.password_path+ click_on 'Enter using password'+ fill_in 'password', with: 'password'+ click_button 'Enter'+ expect(page).to have_current_path(spree.root_path)+ end+ end+end