spree_auth_devise 4.4.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +13 -1
  3. data/Gemfile +8 -1
  4. data/README.md +5 -11
  5. data/config/initializers/devise.rb +1 -1
  6. data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +1 -1
  7. data/lib/controllers/backend/spree/{admin → auth/admin}/base_controller_decorator.rb +2 -2
  8. data/lib/controllers/backend/spree/{admin → auth/admin}/orders/customer_details_controller_decorator.rb +2 -2
  9. data/lib/controllers/backend/spree/{admin → auth/admin}/orders_controller_decorator.rb +2 -2
  10. data/lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb +6 -0
  11. data/lib/controllers/frontend/spree/{checkout_controller_decorator.rb → auth/checkout_controller_decorator.rb} +4 -4
  12. data/lib/controllers/frontend/spree/user_passwords_controller.rb +2 -2
  13. data/lib/controllers/frontend/spree/user_registrations_controller.rb +1 -1
  14. data/lib/controllers/frontend/spree/user_sessions_controller.rb +1 -1
  15. data/lib/mailers/spree/user_mailer.rb +38 -0
  16. data/lib/spree/auth/configuration.rb +10 -0
  17. data/lib/spree/auth/engine.rb +14 -3
  18. data/lib/spree/auth/version.rb +1 -1
  19. data/lib/spree/authentication_helpers.rb +6 -6
  20. data/lib/spree/testing_support/auth_helpers.rb +8 -0
  21. data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +17 -15
  22. data/lib/views/backend/spree/admin/user_passwords/new.html.erb +13 -13
  23. data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +1 -1
  24. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +8 -9
  25. data/lib/views/backend/spree/layouts/login.html.erb +1 -1
  26. data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.html.erb +0 -0
  27. data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.text.erb +0 -0
  28. data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.html.erb +0 -0
  29. data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.text.erb +0 -0
  30. data/lib/views/frontend/spree/user_registrations/new.html.erb +1 -1
  31. data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +2 -2
  32. data/spec/controllers/spree/products_controller_spec.rb +1 -0
  33. data/spec/features/account_spec.rb +1 -0
  34. data/spec/features/admin/sign_in_spec.rb +1 -1
  35. data/spec/features/checkout_spec.rb +4 -3
  36. data/spec/features/confirmation_spec.rb +1 -1
  37. data/spec/features/sign_in_spec.rb +1 -1
  38. data/spec/mailers/user_mailer_spec.rb +3 -3
  39. data/spec/models/user_spec.rb +3 -3
  40. data/spree_auth_devise.gemspec +1 -1
  41. metadata +18 -18
  42. data/app/mailers/spree/user_mailer.rb +0 -23
  43. data/app/models/spree/auth_configuration.rb +0 -8
  44. data/lib/controllers/backend/spree/admin/resource_controller_decorator.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb338dbef2e181d223f6e14b1a8d56bd70e583bb236ecad2e8dd789831961da
4
- data.tar.gz: bb1d7586b41087b8aea34ec13f1bad8be7474b4cd86595b66cab11c4debd0ff5
3
+ metadata.gz: a85c3ec56e4d12970bf8abf6f8365a688cea123c9be66d5e7d9581ca51468bbc
4
+ data.tar.gz: 6cd1ecf12edd93fc0ff505c9d21eadf139f218f1fd2be0870d64d68d833fa712
5
5
  SHA512:
6
- metadata.gz: 2c787c99ace2df8fc064fcf729f00aee7443e3bace6633a9a105c68378cd672eee15fab48230318ce9af3c43b15e763eca90fe16287f114515d7a2f0922bf7a1
7
- data.tar.gz: e0ee63fa233a7e7e1b9300e5c283ee786127fbca22bfbfd352377b0d73b75a054008113cdeb90ceae4e9727cbc7b1007db4257fa2d2fa1f0f14a9c981b7f8fbe
6
+ metadata.gz: 3b55e45f4cd927c1d3a0509f9c4d04ff60d03f1453cb2878911ddd4137834d338cf506db686572ab17e5bc99534dffbc822b36201c92bc6f6a58b1480d8a0041
7
+ data.tar.gz: 1edd8464cdef3be084845fb5eef65e33b9ac86c82e7fb19c35ab6acd29ad60e4a69114bf3a3917f14e150367b0df426c0a85b8340e5110e0443c3c41520f38d8
data/.circleci/config.yml CHANGED
@@ -26,6 +26,9 @@ run_tests: &run_tests
26
26
  keys:
27
27
  - spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
28
28
  - spree-auth-devise-bundle-v9-ruby-2-7
29
+ - run:
30
+ name: Install libvips
31
+ command: sudo apt-get install libvips
29
32
  - run:
30
33
  name: Set bundle path
31
34
  command: bundle config --local path vendor/bundle
@@ -58,6 +61,9 @@ run_tests_3_0: &run_tests_3_0
58
61
  keys:
59
62
  - spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
60
63
  - spree-auth-devise-bundle-v9-ruby-3-0
64
+ - run:
65
+ name: Install libvips
66
+ command: sudo apt-get install libvips
61
67
  - run:
62
68
  name: Set bundle path
63
69
  command: bundle config --local path vendor/bundle
@@ -91,6 +97,9 @@ jobs:
91
97
  keys:
92
98
  - spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
93
99
  - spree-auth-devise-bundle-v9-ruby-2-7
100
+ - run:
101
+ name: Install libvips
102
+ command: sudo apt-get install libvips
94
103
  - run:
95
104
  name: Set bundle path
96
105
  command: bundle config --local path vendor/bundle
@@ -111,6 +120,9 @@ jobs:
111
120
  keys:
112
121
  - spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
113
122
  - spree-auth-devise-bundle-v9-ruby-3-0
123
+ - run:
124
+ name: Install libvips
125
+ command: sudo apt-get install libvips
114
126
  - run:
115
127
  name: Set bundle path
116
128
  command: bundle config --local path vendor/bundle
@@ -174,4 +186,4 @@ workflows:
174
186
  - bundle_ruby_3_0
175
187
  - tests_mysql:
176
188
  requires:
177
- - bundle
189
+ - bundle
data/Gemfile CHANGED
@@ -1,11 +1,18 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails-controller-testing'
4
+ gem 'devise', github: 'heartcombo/devise', branch: 'main'
4
5
  gem 'spree', github: 'spree/spree', branch: 'main'
5
6
  gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
6
- gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
7
7
  gem 'spree_emails', github: 'spree/spree', branch: 'main'
8
+ gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
8
9
  gem 'rspec_junit_formatter', '~> 0.4.1'
9
10
 
11
+ if ENV['DB'] == 'mysql'
12
+ gem 'mysql2'
13
+ else
14
+ gem 'pg', '~> 1.1'
15
+ end
16
+
10
17
  gem 'pry', '~> 0.14.1'
11
18
  gemspec
data/README.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  Provides authentication services for [Spree](https://spreecommerce.org), using the [Devise](https://github.com/plataformatec/devise) gem.
6
6
 
7
+ ## Developed by
8
+
9
+ [![Vendo](https://assets-global.website-files.com/6230c485f2c32ea1b0daa438/623372f40a8c54ca9aea34e8_vendo%202.svg)](https://getvendo.com?utm_source=spree_auth_github)
10
+
11
+ > All-in-one platform for all your Marketplace and B2B eCommerce needs. [Start your 30-day free trial](https://e98esoirr8c.typeform.com/contactvendo?typeform-source=spree_auth_github)
7
12
 
8
13
  ## Installation
9
14
 
@@ -130,14 +135,3 @@ You need to do a quick one-time creation of a test application and then you can
130
135
  Then run the rspec tests.
131
136
 
132
137
  bundle exec rspec
133
-
134
- About Spark Solutions
135
- ----------------------
136
- [![Spark Solutions](http://sparksolutions.co/wp-content/uploads/2015/01/logo-ss-tr-221x100.png)][spark]
137
-
138
- Spree Auth Devise is maintained by [Spark Solutions Sp. z o.o.][spark].
139
-
140
- We are passionate about open source software.
141
- We are [available for hire][spark].
142
-
143
- [spark]:http://sparksolutions.co?utm_source=github
@@ -6,7 +6,7 @@ Devise.setup do |config|
6
6
  config.mailer_sender = 'please-change-me@config-initializers-devise.com'
7
7
 
8
8
  # Configure the class responsible to send e-mails.
9
- config.mailer = 'Spree::UserMailer'
9
+ config.mailer = 'Spree::UserMailer' if defined?(Spree::Emails)
10
10
 
11
11
  # ==> ORM configuration
12
12
  # Load and configure the ORM. Supports :active_record (default) and
@@ -5,7 +5,7 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
5
5
  include Spree::Core::ControllerHelpers::Store
6
6
 
7
7
  helper 'spree/admin/navigation'
8
- layout 'spree/layouts/admin'
8
+ layout 'spree/layouts/login'
9
9
 
10
10
  # Overridden due to bug in Devise.
11
11
  # respond_with resource, :location => new_session_path(resource_name)
@@ -1,4 +1,4 @@
1
- module Spree::Admin::BaseControllerDecorator
1
+ module Spree::Auth::Admin::BaseControllerDecorator
2
2
  # Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
3
3
  # Override this method in your controllers if you want to have special behavior in case the user is not authorized
4
4
  # to access the requested action. For example, a popup window might simply close itself.
@@ -22,4 +22,4 @@ module Spree::Admin::BaseControllerDecorator
22
22
  nil
23
23
  end
24
24
  end
25
- Spree::Admin::BaseController.prepend(Spree::Admin::BaseControllerDecorator)
25
+ ::Spree::Admin::BaseController.prepend(Spree::Auth::Admin::BaseControllerDecorator)
@@ -1,4 +1,4 @@
1
- module Spree::Admin::Orders::CustomerDetailsControllerDecorator
1
+ module Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator
2
2
 
3
3
  def self.prepended(base)
4
4
  base.before_action :check_authorization
@@ -17,4 +17,4 @@ module Spree::Admin::Orders::CustomerDetailsControllerDecorator
17
17
  authorize! action, resource, session[:access_token]
18
18
  end
19
19
  end
20
- Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Admin::Orders::CustomerDetailsControllerDecorator)
20
+ Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator)
@@ -1,4 +1,4 @@
1
- module Spree::Admin::OrdersControllerDecorator
1
+ module Spree::Auth::Admin::OrdersControllerDecorator
2
2
 
3
3
  def self.prepended(base)
4
4
  base.before_action :check_authorization
@@ -22,4 +22,4 @@ module Spree::Admin::OrdersControllerDecorator
22
22
  end
23
23
  end
24
24
  end
25
- Spree::Admin::OrdersController.prepend(Spree::Admin::OrdersControllerDecorator)
25
+ Spree::Admin::OrdersController.prepend(Spree::Auth::Admin::OrdersControllerDecorator)
@@ -0,0 +1,6 @@
1
+ module Spree::Auth::Admin::ResourceControllerDecorator
2
+ def self.prepended(base)
3
+ base.rescue_from CanCan::AccessDenied, with: :unauthorized
4
+ end
5
+ end
6
+ Spree::Admin::ResourceController.prepend(Spree::Auth::Admin::ResourceControllerDecorator)
@@ -1,12 +1,12 @@
1
1
  require 'spree/core/validators/email' if Spree.version.to_f < 3.5
2
- module Spree::CheckoutControllerDecorator
2
+ module Spree::Auth::CheckoutControllerDecorator
3
3
  def self.prepended(base)
4
4
  base.before_action :check_authorization
5
5
  base.before_action :check_registration, except: [:registration, :update_registration]
6
6
  end
7
7
 
8
8
  def registration
9
- @user = Spree.user_class.new
9
+ @user = Spree.user_class.new
10
10
  @title = Spree.t(:registration)
11
11
  end
12
12
 
@@ -16,7 +16,7 @@ module Spree::CheckoutControllerDecorator
16
16
  else
17
17
  flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
18
18
  @user = Spree.user_class.new
19
- render 'registration'
19
+ render 'registration', status: :unprocessable_entity
20
20
  end
21
21
  end
22
22
 
@@ -42,4 +42,4 @@ module Spree::CheckoutControllerDecorator
42
42
  redirect_to spree.checkout_registration_path
43
43
  end
44
44
  end
45
- Spree::CheckoutController.prepend(Spree::CheckoutControllerDecorator)
45
+ Spree::CheckoutController.prepend(Spree::Auth::CheckoutControllerDecorator)
@@ -33,7 +33,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
33
33
  set_flash_message(:notice, :send_instructions) if is_navigational_format?
34
34
  respond_with resource, location: spree.login_path
35
35
  else
36
- respond_with_navigational(resource) { render :new }
36
+ respond_with_navigational(resource) { render :new, status: :unprocessable_entity }
37
37
  end
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
45
45
  self.resource = resource_class.new
46
46
  resource.reset_password_token = params[:spree_user][:reset_password_token]
47
47
  set_flash_message(:error, :cannot_be_blank)
48
- render :edit
48
+ render :edit, status: :unprocessable_entity
49
49
  else
50
50
  super
51
51
  end
@@ -48,7 +48,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
48
48
  end
49
49
  else
50
50
  clean_up_passwords(resource)
51
- render :new
51
+ render :new, status: :unprocessable_entity
52
52
  end
53
53
  end
54
54
 
@@ -38,7 +38,7 @@ class Spree::UserSessionsController < Devise::SessionsController
38
38
  respond_to do |format|
39
39
  format.html {
40
40
  flash.now[:error] = t('devise.failure.invalid')
41
- render :new
41
+ render :new, status: :unprocessable_entity
42
42
  }
43
43
  format.js {
44
44
  render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
@@ -0,0 +1,38 @@
1
+ module Spree
2
+ class UserMailer < BaseMailer
3
+ def reset_password_instructions(user, token, opts = {})
4
+ @user = user
5
+ @current_store = current_store(opts)
6
+ @edit_password_reset_url = edit_password_url(token, @current_store)
7
+
8
+ mail to: user.email, from: from_address, reply_to: reply_to_address,
9
+ subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]),
10
+ store_url: @current_store.url
11
+ end
12
+
13
+ def confirmation_instructions(user, token, opts = {})
14
+ @user = user
15
+ @current_store = current_store(opts)
16
+ @confirmation_url = spree.confirmation_url(confirmation_token: token, host: @current_store.url)
17
+ @email = user.email
18
+
19
+ mail to: user.email, from: from_address, reply_to: reply_to_address,
20
+ subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]),
21
+ store_url: @current_store.url
22
+ end
23
+
24
+ protected
25
+
26
+ def edit_password_url(token, store)
27
+ if frontend_available?
28
+ spree.edit_password_url(reset_password_token: token, host: store.url)
29
+ else
30
+ spree.admin_edit_password_url(reset_password_token: token, host: store.url)
31
+ end
32
+ end
33
+
34
+ def current_store(opts = {})
35
+ @current_store = Spree::Store.find_by(id: opts[:current_store_id]) || Spree::Store.default
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module Auth
3
+ class Configuration < Preferences::Configuration
4
+ preference :registration_step, :boolean, default: true
5
+ preference :signout_after_password_change, :boolean, default: true
6
+ preference :confirmable, :boolean, default: false
7
+ preference :validatable, :boolean, default: true
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,8 @@
1
1
  require 'devise'
2
2
  require 'devise-encryptable'
3
3
 
4
+ require_relative 'configuration'
5
+
4
6
  module Spree
5
7
  module Auth
6
8
  class Engine < Rails::Engine
@@ -8,11 +10,11 @@ module Spree
8
10
  engine_name 'spree_auth'
9
11
 
10
12
  initializer "spree.auth.environment", before: :load_config_initializers do |_app|
11
- Spree::Auth::Config = Spree::AuthConfiguration.new
13
+ Spree::Auth::Config = Spree::Auth::Configuration.new
12
14
  end
13
15
 
14
16
  initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do
15
- Spree.user_class = 'Spree::User' if Spree.user_class.blank? || Spree.user_class.to_s == 'Spree::LegacyUser'
17
+ Spree.user_class = 'Spree::User'
16
18
  end
17
19
 
18
20
  initializer "spree_auth_devise.check_secret_token" do
@@ -55,13 +57,17 @@ module Spree
55
57
  end
56
58
 
57
59
  def self.frontend_available?
58
- @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
60
+ @@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any?
59
61
  end
60
62
 
61
63
  def self.api_available?
62
64
  @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
63
65
  end
64
66
 
67
+ def self.emails_available?
68
+ @@emails_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Emails::Engine')
69
+ end
70
+
65
71
  if backend_available?
66
72
  paths["app/controllers"] << "lib/controllers/backend"
67
73
  paths["app/views"] << "lib/views/backend"
@@ -76,6 +82,11 @@ module Spree
76
82
  paths["app/controllers"] << "lib/controllers/api"
77
83
  end
78
84
 
85
+ if emails_available?
86
+ paths["app/views"] << "lib/views/emails"
87
+ paths["app/mailers"] << "lib/mailers"
88
+ end
89
+
79
90
  config.to_prepare &method(:activate).to_proc
80
91
  end
81
92
  end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  module Auth
3
- VERSION = '4.4.2'.freeze
3
+ VERSION = '4.5.0'.freeze
4
4
 
5
5
  def gem_version
6
6
  Gem::Version.new(VERSION)
@@ -11,16 +11,16 @@ module Spree
11
11
  current_spree_user
12
12
  end
13
13
 
14
- def spree_login_path
15
- spree.login_path
14
+ def spree_login_path(opts = {})
15
+ spree.login_path(opts)
16
16
  end
17
17
 
18
- def spree_signup_path
19
- spree.signup_path
18
+ def spree_signup_path(opts = {})
19
+ spree.signup_path(opts)
20
20
  end
21
21
 
22
- def spree_logout_path
23
- spree.logout_path
22
+ def spree_logout_path(opts = {})
23
+ spree.logout_path(opts)
24
24
  end
25
25
  end
26
26
  end
@@ -39,6 +39,14 @@ module Spree
39
39
  click_link Spree.t(:my_account).upcase
40
40
  end
41
41
  end
42
+
43
+ def wait_for_turbo
44
+ if Spree.version.to_f < 4.5
45
+ expect(page).to have_no_css '.turbolinks-progress-bar'
46
+ else
47
+ expect(page).to have_no_css '.turbo-progress-bar'
48
+ end
49
+ end
42
50
  end
43
51
  end
44
52
  end
@@ -1,16 +1,18 @@
1
- <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
2
-
3
- <h2><%= Spree.t(:change_my_password) %></h2>
4
-
5
- <%= form_for @spree_user, as: :spree_user, url: spree.admin_update_password_path, method: :put do |f| %>
6
- <div class="form-group">
7
- <%= f.label :password, Spree.t(:password) %>
8
- <%= f.password_field :password, class: 'form-control', required: true %>
1
+ <div id="forgot-password" class="card mt-5 shadow-sm">
2
+ <div class="card-body">
3
+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
4
+ <h5 class="card-title"><%= Spree.t(:change_my_password) %></h5>
5
+ <%= form_for @spree_user, as: :spree_user, url: spree.admin_update_password_path, method: :put do |f| %>
6
+ <div class="form-group">
7
+ <%= f.label :password, Spree.t(:password) %>
8
+ <%= f.password_field :password, class: 'form-control', required: true %>
9
+ </div>
10
+ <div class="form-group">
11
+ <%= f.label :password_confirmation, Spree.t(:confirm_password) %>
12
+ <%= f.password_field :password_confirmation, class: 'form-control', required: true %>
13
+ </div>
14
+ <%= f.hidden_field :reset_password_token %>
15
+ <%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block' %>
16
+ <% end %>
9
17
  </div>
10
- <div class="form-group">
11
- <%= f.label :password_confirmation, Spree.t(:confirm_password) %>
12
- <%= f.password_field :password_confirmation, class: 'form-control', required: true %>
13
- </div>
14
- <%= f.hidden_field :reset_password_token %>
15
- <%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block' %>
16
- <% end %>
18
+ </div>
@@ -1,15 +1,15 @@
1
- <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
1
+ <div id="forgot-password" class="card mt-5 shadow-sm">
2
+ <div class="card-body">
3
+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
2
4
 
3
- <div id="forgot-password" class="col-lg-6">
4
- <h1><%= Spree.t(:forgot_password) %></h1>
5
-
6
- <p><%= Spree.t(:instructions_to_reset_password) %></p>
7
-
8
- <%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_reset_password_path, data: { turbo: false } do |f| %>
9
- <div class="form-group">
10
- <%= f.label :email, Spree.t(:email) %>
11
- <%= f.email_field :email, class: 'form-control', required: true %>
12
- </div>
13
- <%= f.submit Spree.t(:reset_password), class: 'btn btn-primary' %>
14
- <% end %>
5
+ <h5 class="card-title"><%= Spree.t(:forgot_password) %></h5>
6
+ <p><%= Spree.t(:instructions_to_reset_password) %></p>
7
+ <%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_reset_password_path, data: { turbo: false } do |f| %>
8
+ <div class="form-group">
9
+ <%= f.label :email, Spree.t(:email) %>
10
+ <%= f.email_field :email, class: 'form-control', required: true %>
11
+ </div>
12
+ <%= f.submit Spree.t(:reset_password), class: 'btn btn-primary' %>
13
+ <% end %>
14
+ </div>
15
15
  </div>
@@ -1,4 +1,4 @@
1
- <div class="alert alert-danger">
1
+ <div class="alert alert-danger m-5">
2
2
  <%= Spree.t(:authorization_failure) %>
3
3
  </div>
4
4
  <!-- Add your own custom access denied message here if you like -->
@@ -1,17 +1,16 @@
1
- <% if flash[:alert] %>
2
- <div class="alert alert-danger"><%= flash[:alert] %></div>
3
- <% end %>
4
-
5
- <div data-hook="login" class="card border-0">
1
+ <div data-hook="login" class="card mt-5 shadow-sm">
6
2
  <div class="card-body">
3
+ <% if flash[:error] %>
4
+ <div class="alert alert-danger"><%= flash[:error] %></div>
5
+ <% end %>
6
+ <h5 class="card-title"><%= Spree.t(:login) %></h5>
7
+
7
8
  <%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
8
9
  <div id="password-credentials">
9
- <div class="form-group text-center">
10
- <%= f.label :email, Spree.t(:email) %>
10
+ <div class="form-group">
11
11
  <%= f.email_field :email, class: 'form-control', tabindex: 1, placeholder: Spree.t(:email) %>
12
12
  </div>
13
- <div class="form-group text-center">
14
- <%= f.label :password, Spree.t(:password) %>
13
+ <div class="form-group">
15
14
  <%= f.password_field :password, :class => 'form-control', :tabindex => 2, placeholder: Spree.t(:password) %>
16
15
  </div>
17
16
  </div>
@@ -8,7 +8,7 @@
8
8
  <%= render partial: 'spree/admin/shared/head' %>
9
9
  </head>
10
10
 
11
- <body class="pt-5">
11
+ <body class="admin bg-light pt-5">
12
12
  <div class="container">
13
13
 
14
14
  <div class="row">
@@ -3,7 +3,7 @@
3
3
  <div class="col-lg-6 offset-lg-3">
4
4
  <h3 class="spree-header spree-mb-large spree-mt-large"><%= Spree.t(:new_customer) %></h3>
5
5
  <div id="new-customer" data-hook="login">
6
- <%= form_for resource, as: :spree_user, url: spree.registration_path do |f| %>
6
+ <%= form_for resource, as: :spree_user, url: spree.registration_path, data: { turbo: false } do |f| %>
7
7
  <div data-hook="signup_inside_form">
8
8
  <%= render partial: 'spree/shared/user_form', locals: { f: f, remember_me_field: true } %>
9
9
  <div><%= f.submit Spree.t(:sign_up), class: 'btn btn-primary btn-block spree-btn mb-5' %></div>
@@ -32,7 +32,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
32
32
  context 'when updating password with blank password' do
33
33
  let(:params) {
34
34
  {
35
- id: user.send_reset_password_instructions(Spree::Store.current),
35
+ id: user.send_reset_password_instructions(Spree::Store.default),
36
36
  user: {
37
37
  password: '',
38
38
  password_confirmation: ''
@@ -49,7 +49,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
49
49
  context 'when updating password with specified password' do
50
50
  let(:params) {
51
51
  {
52
- id: user.send_reset_password_instructions(Spree::Store.current),
52
+ id: user.send_reset_password_instructions(Spree::Store.default),
53
53
  user: {
54
54
  password: password,
55
55
  password_confirmation: password
@@ -17,6 +17,7 @@ RSpec.describe Spree::ProductsController, type: :controller do
17
17
  end
18
18
 
19
19
  it 'cannot view non-active products' do
20
+ skip if Spree.version.to_f > 4.0
20
21
  allow(user).to receive(:has_spree_role?) { false }
21
22
 
22
23
  # this behaviour was introduced in rails 5.1 & Spree 3.5
@@ -28,6 +28,7 @@ RSpec.feature 'Accounts', type: :feature do
28
28
  expect(page).to have_text 'email@person.com'
29
29
 
30
30
  find('a.account-page-user-info-item-title-edit').click
31
+ wait_for_turbo
31
32
 
32
33
  fill_in 'Password', with: 'foobar'
33
34
  fill_in 'Password Confirmation', with: 'foobar'
@@ -44,6 +44,6 @@ RSpec.feature 'Admin - Sign In', type: :feature do
44
44
  expect(page).to have_text 'admin@person.com'
45
45
  end
46
46
  end
47
- expect(current_path).to eq '/admin/orders'
47
+ expect(current_path).to match('/admin')
48
48
  end
49
49
  end
@@ -73,7 +73,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
73
73
  end
74
74
 
75
75
  # Regression test for #890
76
- scenario 'associate an incomplete guest order with user after successful password reset' do
76
+ xscenario 'associate an incomplete guest order with user after successful password reset' do
77
77
  add_to_cart(mug)
78
78
 
79
79
  visit spree.login_path
@@ -81,12 +81,12 @@ RSpec.feature 'Checkout', :js, type: :feature do
81
81
  fill_in('Email', with: 'email@person.com')
82
82
  find('#spree_user_email').set('email@person.com')
83
83
 
84
- click_button 'Reset my password'
84
+ expect { click_button 'Reset my password' }.to change { ActionMailer::Base.deliveries.size }.by(1)
85
85
 
86
86
  # Need to do this now because the token stored in the DB is the encrypted version
87
87
  # The 'plain-text' version is sent in the email and there's one way to get that!
88
88
  reset_password_email = ActionMailer::Base.deliveries.first
89
- token_url_regex = /^http:\/\/www.example.com\/user\/spree_user\/password\/edit\?reset_password_token=(.*)$/
89
+ token_url_regex = /^http:\/\/www.example.com\/password\/change\?reset_password_token=(.*)$/
90
90
  token = token_url_regex.match(reset_password_email.body.encoded)[1]
91
91
 
92
92
  visit spree.edit_spree_user_password_path(reset_password_token: token.strip).tr("%0D","")
@@ -103,6 +103,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
103
103
  click_button 'Save and Continue'
104
104
 
105
105
  expect(page).not_to have_text 'Email is invalid'
106
+ ActiveJob::Base.queue_adapter = :test
106
107
  end
107
108
 
108
109
  scenario 'allow a user to register during checkout' do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.feature 'Confirmation', type: :feature, confirmable: true do
4
4
  before do
5
- expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.current.id }).and_return(double(deliver: true))
5
+ expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
6
6
  end
7
7
 
8
8
  background do
@@ -45,7 +45,7 @@ RSpec.feature 'Sign In', type: :feature do
45
45
  expect(page).to have_text 'admin@person.com'
46
46
  end
47
47
  end
48
- expect(current_path).to eq '/admin/orders'
48
+ expect(current_path).to match('/admin')
49
49
  end
50
50
 
51
51
  it 'should store the user previous location' do
@@ -5,7 +5,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
5
5
  describe '#reset_password_instructions' do
6
6
  describe 'message contents' do
7
7
  before do
8
- @message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.current.id })
8
+ @message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id })
9
9
  end
10
10
 
11
11
  context 'subject includes' do
@@ -22,7 +22,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
22
22
 
23
23
  context 'body includes' do
24
24
  it 'password reset url' do
25
- expect(@message.body.encoded).to include "http://#{store.url}/user/spree_user/password/edit"
25
+ expect(@message.body.encoded).to include "http://#{store.url}/password/change"
26
26
  end
27
27
  end
28
28
  end
@@ -30,7 +30,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
30
30
  describe 'legacy support for User object' do
31
31
  it 'sends an email' do
32
32
  expect {
33
- described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.current.id }).deliver_now
33
+ described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id }).deliver_now
34
34
  }.to change(ActionMailer::Base.deliveries, :size).by(1)
35
35
  end
36
36
  end
@@ -9,7 +9,7 @@ RSpec.describe Spree::User, type: :model do
9
9
 
10
10
  it 'generates the reset password token' do
11
11
  user = build(:user)
12
- current_store = Spree::Store.current
12
+ current_store = Spree::Store.default
13
13
  expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, { current_store_id: current_store.id }).and_return(double(deliver: true))
14
14
  user.send_reset_password_instructions(current_store)
15
15
  expect(user.reset_password_token).not_to be_nil
@@ -94,7 +94,7 @@ RSpec.describe Spree::User, type: :model do
94
94
 
95
95
  describe "confirmable" do
96
96
  it "is confirmable if the confirmable option is enabled", confirmable: true do
97
- Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.current.id }).and_return(double(deliver: true))
97
+ Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
98
98
  expect(Spree.user_class.devise_modules).to include(:confirmable)
99
99
  end
100
100
 
@@ -112,7 +112,7 @@ RSpec.describe Spree::User, type: :model do
112
112
  user.email = FFaker::Internet.email
113
113
  user.password = user.password_confirmation = 'pass1234'
114
114
  user.save
115
-
115
+
116
116
  expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
117
117
  user, anything, { current_store_id: default_store.id }).and_return(double(deliver: true)
118
118
  )
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_dependency 'devise', '~> 4.7'
34
34
  s.add_dependency 'devise-encryptable', '0.2.0'
35
35
 
36
- spree_version = '>= 4.3.0.rc1'
36
+ spree_version = '>= 4.5.0'
37
37
  s.add_dependency 'spree_core', spree_version
38
38
  s.add_dependency 'spree_extension'
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-12-03 00:00:00.000000000 Z
12
+ date: 2022-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 4.3.0.rc1
48
+ version: 4.5.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 4.3.0.rc1
55
+ version: 4.5.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: spree_extension
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -102,13 +102,7 @@ files:
102
102
  - app/controllers/metal_decorator.rb
103
103
  - app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb
104
104
  - app/controllers/spree/api/v2/storefront/passwords_controller.rb
105
- - app/mailers/spree/user_mailer.rb
106
- - app/models/spree/auth_configuration.rb
107
105
  - app/models/spree/user.rb
108
- - app/views/spree/user_mailer/confirmation_instructions.html.erb
109
- - app/views/spree/user_mailer/confirmation_instructions.text.erb
110
- - app/views/spree/user_mailer/reset_password_instructions.html.erb
111
- - app/views/spree/user_mailer/reset_password_instructions.text.erb
112
106
  - bin/rails
113
107
  - config.ru
114
108
  - config/initializers/devise.rb
@@ -136,13 +130,13 @@ files:
136
130
  - db/migrate/20150416152553_add_missing_indices_on_user.rb
137
131
  - db/migrate/20210728103922_change_type_of_ship_address_id_and_bill_address_id_for_spree_users.rb
138
132
  - db/seeds.rb
139
- - lib/controllers/backend/spree/admin/base_controller_decorator.rb
140
- - lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb
141
- - lib/controllers/backend/spree/admin/orders_controller_decorator.rb
142
- - lib/controllers/backend/spree/admin/resource_controller_decorator.rb
143
133
  - lib/controllers/backend/spree/admin/user_passwords_controller.rb
144
134
  - lib/controllers/backend/spree/admin/user_sessions_controller.rb
145
- - lib/controllers/frontend/spree/checkout_controller_decorator.rb
135
+ - lib/controllers/backend/spree/auth/admin/base_controller_decorator.rb
136
+ - lib/controllers/backend/spree/auth/admin/orders/customer_details_controller_decorator.rb
137
+ - lib/controllers/backend/spree/auth/admin/orders_controller_decorator.rb
138
+ - lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb
139
+ - lib/controllers/frontend/spree/auth/checkout_controller_decorator.rb
146
140
  - lib/controllers/frontend/spree/user_confirmations_controller.rb
147
141
  - lib/controllers/frontend/spree/user_passwords_controller.rb
148
142
  - lib/controllers/frontend/spree/user_registrations_controller.rb
@@ -150,7 +144,9 @@ files:
150
144
  - lib/controllers/frontend/spree/users_controller.rb
151
145
  - lib/generators/spree/auth/install/install_generator.rb
152
146
  - lib/generators/spree/auth/install/templates/config/initializers/devise.rb
147
+ - lib/mailers/spree/user_mailer.rb
153
148
  - lib/spree/auth.rb
149
+ - lib/spree/auth/configuration.rb
154
150
  - lib/spree/auth/devise.rb
155
151
  - lib/spree/auth/engine.rb
156
152
  - lib/spree/auth/version.rb
@@ -165,6 +161,10 @@ files:
165
161
  - lib/views/backend/spree/admin/user_sessions/new.html.erb
166
162
  - lib/views/backend/spree/layouts/admin/_login_nav.html.erb
167
163
  - lib/views/backend/spree/layouts/login.html.erb
164
+ - lib/views/emails/spree/user_mailer/confirmation_instructions.html.erb
165
+ - lib/views/emails/spree/user_mailer/confirmation_instructions.text.erb
166
+ - lib/views/emails/spree/user_mailer/reset_password_instructions.html.erb
167
+ - lib/views/emails/spree/user_mailer/reset_password_instructions.text.erb
168
168
  - lib/views/frontend/spree/shared/_flashes.html.erb
169
169
  - lib/views/frontend/spree/shared/_login_bar.html.erb
170
170
  - lib/views/frontend/spree/user_passwords/edit.html.erb
@@ -213,9 +213,9 @@ licenses:
213
213
  - BSD-3-Clause
214
214
  metadata:
215
215
  bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
216
- changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.4.2
216
+ changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.5.0
217
217
  documentation_uri: https://guides.spreecommerce.org/
218
- source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.4.2
218
+ source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.5.0
219
219
  post_install_message:
220
220
  rdoc_options: []
221
221
  require_paths:
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements:
234
234
  - none
235
- rubygems_version: 3.2.22
235
+ rubygems_version: 3.0.9
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Provides authentication and authorization services for use with Spree by
@@ -1,23 +0,0 @@
1
- module Spree
2
- class UserMailer < defined?(Spree::BaseMailer) ? Spree::BaseMailer : ActionMailer::Base
3
- def reset_password_instructions(user, token, *_args)
4
- current_store_id = _args.inject(:merge)[:current_store_id]
5
- @current_store = Spree::Store.find(current_store_id) || Spree::Store.current
6
- @locale = @current_store.has_attribute?(:default_locale) ? @current_store.default_locale : I18n.default_locale
7
- I18n.locale = @locale if @locale.present?
8
- @edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @current_store.url)
9
- @user = user
10
-
11
- mail to: user.email, from: @current_store.mail_from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]), store_url: @current_store.url
12
- end
13
-
14
- def confirmation_instructions(user, token, _opts = {})
15
- current_store_id = _opts[:current_store_id]
16
- @current_store = Spree::Store.find(current_store_id) || Spree::Store.current
17
- @confirmation_url = spree.confirmation_url(confirmation_token: token, host: Spree::Store.current.url)
18
- @email = user.email
19
-
20
- mail to: user.email, from: @current_store.mail_from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]), store_url: @current_store.url
21
- end
22
- end
23
- end
@@ -1,8 +0,0 @@
1
- module Spree
2
- class AuthConfiguration < Preferences::Configuration
3
- preference :registration_step, :boolean, default: true
4
- preference :signout_after_password_change, :boolean, default: true
5
- preference :confirmable, :boolean, default: false
6
- preference :validatable, :boolean, default: true
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- module Spree::Admin::ResourceControllerDecorator
2
- def self.prepended(base)
3
- base.rescue_from CanCan::AccessDenied, with: :unauthorized
4
- end
5
- end
6
- Spree::Admin::ResourceController.prepend(Spree::Admin::ResourceControllerDecorator)