From 8cdb8a81691464e108d2fe178b1004b1d9da752b Mon Sep 17 00:00:00 2001 From: Brett Allred Date: Wed, 1 Aug 2018 17:21:08 -0600 Subject: [PATCH 1/3] Add registerable as an option --- app/models/spree/auth_configuration.rb | 1 + app/models/spree/user.rb | 3 ++- config/routes.rb | 4 ++-- spree_auth_devise.gemspec | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/spree/auth_configuration.rb b/app/models/spree/auth_configuration.rb index 9a96fe8c0..1c014ce50 100644 --- a/app/models/spree/auth_configuration.rb +++ b/app/models/spree/auth_configuration.rb @@ -4,5 +4,6 @@ class AuthConfiguration < Preferences::Configuration preference :signout_after_password_change, :boolean, default: true preference :confirmable, :boolean, default: false preference :validatable, :boolean, default: true + preference :registerable, :boolean, default: true end end diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index c2e3f87bb..79f3ed8ca 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -4,10 +4,11 @@ class User < Spree::Base include UserMethods include UserPaymentSource - devise :database_authenticatable, :registerable, :recoverable, + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :encryptable, encryptor: 'authlogic_sha512' devise :confirmable if Spree::Auth::Config[:confirmable] devise :validatable if Spree::Auth::Config[:validatable] + devise :registerable if Spree::Auth::Config[:registerable] acts_as_paranoid after_destroy :scramble_email_and_password diff --git a/config/routes.rb b/config/routes.rb index a45a87d62..212ff1b1b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,8 +15,8 @@ get '/login' => 'user_sessions#new', :as => :login post '/login' => 'user_sessions#create', :as => :create_new_session get '/logout' => 'user_sessions#destroy', :as => :logout - get '/signup' => 'user_registrations#new', :as => :signup - post '/signup' => 'user_registrations#create', :as => :registration + get '/signup' => 'user_registrations#new', :as => :signup if Spree::Auth::Config[:registerable] + post '/signup' => 'user_registrations#create', :as => :registration if Spree::Auth::Config[:registerable] get '/password/recover' => 'user_passwords#new', :as => :recover_password post '/password/recover' => 'user_passwords#create', :as => :reset_password get '/password/change' => 'user_passwords#edit', :as => :edit_password diff --git a/spree_auth_devise.gemspec b/spree_auth_devise.gemspec index 52bfd5d2f..872ba45bc 100644 --- a/spree_auth_devise.gemspec +++ b/spree_auth_devise.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'factory_bot', '~> 4.7' s.add_development_dependency 'ffaker' s.add_development_dependency 'launchy' - s.add_development_dependency 'mysql2', '~> 0.3.18' + s.add_development_dependency 'mysql2', '>= 0.3.18', '<= 0.5.2' s.add_development_dependency 'pg', '~> 0.18' s.add_development_dependency 'selenium-webdriver' s.add_development_dependency 'pry' From 1607aca509a3127b58b085b1f46a8b294dd3e4ca Mon Sep 17 00:00:00 2001 From: Brett Allred Date: Wed, 1 Aug 2018 19:14:48 -0600 Subject: [PATCH 2/3] Fix views --- lib/views/frontend/spree/user_sessions/new.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/views/frontend/spree/user_sessions/new.html.erb b/lib/views/frontend/spree/user_sessions/new.html.erb index fdce6140d..424dd0e49 100755 --- a/lib/views/frontend/spree/user_sessions/new.html.erb +++ b/lib/views/frontend/spree/user_sessions/new.html.erb @@ -8,7 +8,9 @@ <%= render :partial => 'spree/shared/login' %>
<%= Spree.t(:or) %> - <%= link_to Spree.t(:create_a_new_account), spree.signup_path %> | + <% if Spree::Auth::Config[:registerable] %> + <%= link_to Spree.t(:create_a_new_account), spree.signup_path %> | + <% end %> <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
From dbb37c5d364b35a112c7282f52fdddc223d3c2e0 Mon Sep 17 00:00:00 2001 From: Brett Allred Date: Wed, 1 Aug 2018 21:24:14 -0600 Subject: [PATCH 3/3] fix signup path bug: --- lib/spree/authentication_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spree/authentication_helpers.rb b/lib/spree/authentication_helpers.rb index 8ec570fc9..6966530b8 100644 --- a/lib/spree/authentication_helpers.rb +++ b/lib/spree/authentication_helpers.rb @@ -16,7 +16,7 @@ def spree_login_path end def spree_signup_path - spree.signup_path + Spree::Auth::Config[:registerable] ? spree.signup_path : '/' end def spree_logout_path