spree_auth_devise 4.3.2 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +2 -0
  3. data/.github/dependabot.yml +11 -0
  4. data/.travis.yml +1 -11
  5. data/Gemfile +5 -1
  6. data/README.md +1 -1
  7. data/app/mailers/spree/user_mailer.rb +4 -4
  8. data/app/models/spree/user.rb +5 -1
  9. data/config/initializers/warden.rb +1 -1
  10. data/config/routes.rb +3 -1
  11. data/db/migrate/20210728103922_change_type_of_ship_address_id_and_bill_address_id_for_spree_users.rb +8 -0
  12. data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +17 -1
  13. data/{app/controllers → lib/controllers/frontend}/spree/user_confirmations_controller.rb +9 -6
  14. data/{app/controllers → lib/controllers/frontend}/spree/user_passwords_controller.rb +8 -9
  15. data/{app/controllers → lib/controllers/frontend}/spree/user_registrations_controller.rb +8 -9
  16. data/{app/controllers → lib/controllers/frontend}/spree/user_sessions_controller.rb +11 -12
  17. data/lib/controllers/frontend/spree/users_controller.rb +8 -3
  18. data/lib/spree/auth/engine.rb +1 -9
  19. data/lib/spree/auth/version.rb +9 -0
  20. data/lib/spree/testing_support/auth_helpers.rb +18 -10
  21. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
  22. data/{app/views → lib/views/frontend}/spree/user_passwords/edit.html.erb +0 -0
  23. data/{app/views → lib/views/frontend}/spree/user_passwords/new.html.erb +0 -0
  24. data/{app/views → lib/views/frontend}/spree/user_registrations/new.html.erb +0 -0
  25. data/{app/views → lib/views/frontend}/spree/user_sessions/new.html.erb +0 -0
  26. data/spec/controllers/spree/user_sessions_controller_spec.rb +13 -1
  27. data/spec/controllers/spree/users_controller_spec.rb +1 -1
  28. data/spec/features/account_spec.rb +2 -2
  29. data/spec/features/admin/orders_spec.rb +4 -2
  30. data/spec/features/admin/sign_in_spec.rb +5 -4
  31. data/spec/features/admin/sign_out_spec.rb +3 -3
  32. data/spec/features/admin_permissions_spec.rb +1 -1
  33. data/spec/features/checkout_spec.rb +2 -2
  34. data/spec/features/confirmation_spec.rb +1 -4
  35. data/spec/features/order_spec.rb +2 -2
  36. data/spec/features/sign_in_spec.rb +29 -6
  37. data/spec/features/sign_out_spec.rb +2 -2
  38. data/spec/models/user_spec.rb +65 -7
  39. data/spec/requests/spree/frontend/user_update_spec.rb +42 -0
  40. data/spec/spec_helper.rb +4 -0
  41. data/spec/support/confirm_helpers.rb +22 -8
  42. data/spree_auth_devise.gemspec +6 -2
  43. metadata +24 -32
  44. data/Appraisals +0 -9
  45. data/app/services/spree/account/create.rb +0 -19
  46. data/app/services/spree/account/update.rb +0 -17
  47. data/gemfiles/spree_4_1.gemfile +0 -8
  48. data/gemfiles/spree_master.gemfile +0 -8
  49. data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +0 -41
  50. data/spec/support/user_helper.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 632dbf0ba8467163e8cff132261a9173f5c4a9b9b670c3e93599d66bb07575a1
4
- data.tar.gz: 2e400ddce6368507961c686f4e094eb9c09ab47ebb8ecd97ade3c1f425e5ce5d
3
+ metadata.gz: 565373eb7dea3f9d8862356201ff23400aae3c29f5b77114d223de0f146f4dda
4
+ data.tar.gz: '05666786abb74456941e152e4217e10e9bd26ac8f10655a069ad499c39410352'
5
5
  SHA512:
6
- metadata.gz: b07a757183970dc752ad4187daf50acca0783f1914ee4f0ed99a68f533a5e98ee5525dac009bd509760f70c74577f3f6de0d3acf30060bd4319f1b24a495bd02
7
- data.tar.gz: 1c0fb11dbf07ed2c308a7bd693118254a933c5204e535d0765958679ae6576a098f71671eb18c42b7943e7b1fd18af32eaf1b8273664090e6a8e7dd625a804b6
6
+ metadata.gz: 89bfa5e3bbf864449b1937682af334f85201f484f23360d5dc40834a9a0d31999c06380531eb883f547dfe34e1df8072fb45c4707918d3eeeefc972649af8438
7
+ data.tar.gz: 39c55713494bd990c1cb8a7ff5f978227e8e62136564ae76c7f840b3028dcf30d86b8f6f2e94d52397aab7a66c2b0dc96804c4e3cd0b65454b9cd89a64c7a129
data/.gem_release.yml ADDED
@@ -0,0 +1,2 @@
1
+ bump:
2
+ file: 'lib/spree/auth/version.rb'
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ ignore:
9
+ - dependency-name: pry
10
+ versions:
11
+ - 0.14.0
data/.travis.yml CHANGED
@@ -11,6 +11,7 @@ addons:
11
11
  services:
12
12
  - mysql
13
13
  - postgresql
14
+ - redis-server
14
15
 
15
16
  language: ruby
16
17
 
@@ -22,17 +23,6 @@ env:
22
23
  - DB=mysql
23
24
  - DB=postgres
24
25
 
25
- gemfile:
26
- - gemfiles/spree_4_1.gemfile
27
- - gemfiles/spree_master.gemfile
28
-
29
- jobs:
30
- exclude:
31
- - rvm: 3.0
32
- gemfile: gemfiles/spree_4_1.gemfile
33
- allow_failures:
34
- - gemfile: gemfiles/spree_master.gemfile
35
-
36
26
  before_install:
37
27
  - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
38
28
 
data/Gemfile CHANGED
@@ -1,6 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails-controller-testing'
4
- gem 'spree', github: 'spree/spree', branch: 'master'
4
+ gem 'spree', '~> 4.3.0'
5
+ gem 'spree_backend', '~> 4.3.0'
6
+ gem 'spree_frontend', '~> 4.3.0'
7
+ gem 'spree_emails', '~> 4.3.0'
5
8
 
9
+ gem 'pry', '~> 0.14.1'
6
10
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Spree Auth (Devise)
2
2
 
3
- [![Build Status](https://travis-ci.org/spree/spree_auth_devise.svg?branch=master)](https://travis-ci.org/spree/spree_auth_devise)
3
+ [![Build Status](https://travis-ci.com/spree/spree_auth_devise.svg?branch=main)](https://travis-ci.org/spree/spree_auth_devise)
4
4
  [![Code Climate](https://codeclimate.com/github/spree/spree_auth_devise/badges/gpa.svg)](https://codeclimate.com/github/spree/spree_auth_devise)
5
5
 
6
6
  Provides authentication services for [Spree](https://spreecommerce.org), using the [Devise](https://github.com/plataformatec/devise) gem.
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- class UserMailer < BaseMailer
2
+ class UserMailer < defined?(Spree::BaseMailer) ? Spree::BaseMailer : ActionMailer::Base
3
3
  def reset_password_instructions(user, token, *_args)
4
4
  current_store_id = _args.inject(:merge)[:current_store_id]
5
5
  @current_store = Spree::Store.find(current_store_id) || Spree::Store.current
@@ -8,16 +8,16 @@ module Spree
8
8
  @edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @current_store.url)
9
9
  @user = user
10
10
 
11
- mail to: user.email, from: from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]), store_url: @current_store.url
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
12
  end
13
13
 
14
14
  def confirmation_instructions(user, token, _opts = {})
15
15
  current_store_id = _opts[:current_store_id]
16
16
  @current_store = Spree::Store.find(current_store_id) || Spree::Store.current
17
- @confirmation_url = spree_user_confirmation_url(confirmation_token: token, host: Spree::Store.current.url)
17
+ @confirmation_url = spree.confirmation_url(confirmation_token: token, host: Spree::Store.current.url)
18
18
  @email = user.email
19
19
 
20
- mail to: user.email, from: from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]), store_url: @current_store.url
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
21
  end
22
22
  end
23
23
  end
@@ -48,7 +48,7 @@ module Spree
48
48
  end
49
49
 
50
50
  opts = pending_reconfirmation? ? { to: unconfirmed_email } : {}
51
- opts[:current_store_id] = current_store.id
51
+ opts[:current_store_id] = current_store&.id || Spree::Store.default.id
52
52
  send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
53
53
  end
54
54
 
@@ -71,6 +71,10 @@ module Spree
71
71
 
72
72
  protected
73
73
 
74
+ def send_on_create_confirmation_instructions(current_store = nil)
75
+ send_confirmation_instructions(current_store || Spree::Store.default)
76
+ end
77
+
74
78
  def password_required?
75
79
  !persisted? || password.present? || password_confirmation.present?
76
80
  end
@@ -3,7 +3,7 @@ Warden::Manager.after_set_user except: :fetch do |user, auth, _opts|
3
3
  token = auth.cookies.signed[:guest_token] || auth.cookies.signed[:token]
4
4
  token_attr = Spree::Order.has_attribute?(:token) ? :token : :guest_token
5
5
 
6
- if token.present? && user.is_a?(Spree::User)
6
+ if token.present? && user.is_a?(Spree.user_class)
7
7
  Spree::Order.incomplete.where(token_attr => token, user_id: nil).each do |order|
8
8
  order.associate_user!(user)
9
9
  end
data/config/routes.rb CHANGED
@@ -21,7 +21,7 @@ Spree::Core::Engine.add_routes do
21
21
  post '/password/recover' => 'user_passwords#create', :as => :reset_password
22
22
  get '/password/change' => 'user_passwords#edit', :as => :edit_password
23
23
  put '/password/change' => 'user_passwords#update', :as => :update_password
24
- get '/confirm' => 'user_confirmations#show', :as => :confirmation if Spree::Auth::Config[:confirmable]
24
+ get '/confirm' => 'user_confirmations#show', :as => :confirmation
25
25
  end
26
26
 
27
27
  get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
@@ -42,6 +42,8 @@ Spree::Core::Engine.add_routes do
42
42
  get '/login' => 'user_sessions#new', :as => :login
43
43
  post '/login' => 'user_sessions#create', :as => :create_new_session
44
44
  get '/logout' => 'user_sessions#destroy', :as => :logout
45
+ get '/password/recover' => 'user_passwords#new', :as => :recover_password
46
+ post '/password/recover' => 'user_passwords#create', :as => :reset_password
45
47
  end
46
48
  end
47
49
 
@@ -0,0 +1,8 @@
1
+ class ChangeTypeOfShipAddressIdAndBillAddressIdForSpreeUsers < ActiveRecord::Migration[4.2]
2
+ def change
3
+ change_table(:spree_users) do |t|
4
+ t.change :ship_address_id, :bigint
5
+ t.change :bill_address_id, :bigint
6
+ end
7
+ end
8
+ end
@@ -14,7 +14,7 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
14
14
  if spree_user_signed_in?
15
15
  respond_to do |format|
16
16
  format.html {
17
- flash[:success] = Spree.t(:logged_in_succesfully)
17
+ flash[:success] = Spree.t(:logged_in_successfully)
18
18
  redirect_back_or_default(after_sign_in_path_for(spree_current_user))
19
19
  }
20
20
  format.js {
@@ -59,4 +59,20 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
59
59
  "spree/layouts/admin"
60
60
  end
61
61
  end
62
+
63
+ def respond_to_on_destroy
64
+ # We actually need to hardcode this as Rails default responder doesn't
65
+ # support returning empty response on GET request
66
+ respond_to do |format|
67
+ format.all { head :no_content }
68
+ format.any(*navigational_formats) { redirect_to after_sign_out_redirect(resource_name) }
69
+ end
70
+ end
71
+
72
+ def after_sign_out_redirect(resource_or_scope)
73
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
74
+ router_name = Devise.mappings[scope].router_name
75
+ context = router_name ? send(router_name) : self
76
+ context.respond_to?(:admin_login_path) ? context.admin_login_path : "/"
77
+ end
62
78
  end
@@ -6,13 +6,16 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
13
+
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
16
19
 
17
20
  before_action :set_current_order
18
21
 
@@ -6,17 +6,16 @@ class Spree::UserPasswordsController < Devise::PasswordsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :set_current_order
22
21
 
@@ -6,17 +6,16 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :check_permissions, only: [:edit, :update]
22
21
  before_action :set_current_order
@@ -6,17 +6,16 @@ class Spree::UserSessionsController < Devise::SessionsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :set_current_order
22
21
 
@@ -26,7 +25,7 @@ class Spree::UserSessionsController < Devise::SessionsController
26
25
  if spree_user_signed_in?
27
26
  respond_to do |format|
28
27
  format.html {
29
- flash[:success] = Spree.t(:logged_in_succesfully)
28
+ flash[:success] = Spree.t(:logged_in_successfully)
30
29
  redirect_back_or_default(after_sign_in_redirect(spree_current_user))
31
30
  }
32
31
  format.js {
@@ -66,7 +65,7 @@ class Spree::UserSessionsController < Devise::SessionsController
66
65
  end
67
66
 
68
67
  def after_sign_in_redirect(resource_or_scope)
69
- stored_location_for(resource_or_scope) || account_path
68
+ stored_location_for(resource_or_scope) || spree.account_path
70
69
  end
71
70
 
72
71
  def respond_to_on_destroy
@@ -82,6 +81,6 @@ class Spree::UserSessionsController < Devise::SessionsController
82
81
  scope = Devise::Mapping.find_scope!(resource_or_scope)
83
82
  router_name = Devise.mappings[scope].router_name
84
83
  context = router_name ? send(router_name) : self
85
- context.respond_to?(:login_path) ? context.login_path : "/"
84
+ context.respond_to?(:login_path) ? context.login_path : spree.root_path
86
85
  end
87
86
  end
@@ -1,12 +1,16 @@
1
1
  class Spree::UsersController < Spree::StoreController
2
2
  before_action :set_current_order, except: :show
3
- prepend_before_action :load_object, only: [:show, :edit, :update]
4
3
  prepend_before_action :authorize_actions, only: :new
5
4
 
6
5
  include Spree::Core::ControllerHelpers
7
6
 
8
7
  def show
9
- @orders = @user.orders.complete.order('completed_at desc')
8
+ load_object
9
+ @orders = @user.orders.for_store(current_store).complete.order('completed_at desc')
10
+ end
11
+
12
+ def edit
13
+ load_object
10
14
  end
11
15
 
12
16
  def create
@@ -24,6 +28,7 @@ class Spree::UsersController < Spree::StoreController
24
28
  end
25
29
 
26
30
  def update
31
+ load_object
27
32
  if @user.update(user_params)
28
33
  if params[:user][:password].present?
29
34
  # this logic needed b/c devise wants to log us out after password changes
@@ -34,7 +39,7 @@ class Spree::UsersController < Spree::StoreController
34
39
  bypass_sign_in(@user)
35
40
  end
36
41
  end
37
- redirect_to spree.account_url, notice: Spree.t(:account_updated)
42
+ redirect_to spree.account_path, notice: Spree.t(:account_updated)
38
43
  else
39
44
  render :edit
40
45
  end
@@ -12,7 +12,7 @@ module Spree
12
12
  end
13
13
 
14
14
  initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do
15
- Spree.user_class = "Spree::User"
15
+ Spree.user_class = 'Spree::User' if Spree.user_class.blank? || Spree.user_class.to_s == 'Spree::LegacyUser'
16
16
  end
17
17
 
18
18
  initializer "spree_auth_devise.check_secret_token" do
@@ -29,19 +29,11 @@ module Spree
29
29
  Rails.configuration.cache_classes ? require(c) : load(c)
30
30
  end
31
31
  if Spree::Auth::Engine.backend_available?
32
- Rails.application.config.assets.precompile += [
33
- 'lib/assets/javascripts/spree/backend/spree_auth.js',
34
- 'lib/assets/javascripts/spree/backend/spree_auth.css'
35
- ]
36
32
  Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/backend/*/*/*_decorator*.rb")) do |c|
37
33
  Rails.configuration.cache_classes ? require(c) : load(c)
38
34
  end
39
35
  end
40
36
  if Spree::Auth::Engine.frontend_available?
41
- Rails.application.config.assets.precompile += [
42
- 'lib/assets/javascripts/spree/frontend/spree_auth.js',
43
- 'lib/assets/javascripts/spree/frontend/spree_auth.css'
44
- ]
45
37
  Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/**/*_decorator*.rb")) do |c|
46
38
  Rails.configuration.cache_classes ? require(c) : load(c)
47
39
  end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module Auth
3
+ VERSION = '4.4.1'.freeze
4
+
5
+ def gem_version
6
+ Gem::Version.new(VERSION)
7
+ end
8
+ end
9
+ end
@@ -1,34 +1,42 @@
1
1
  module Spree
2
2
  module TestingSupport
3
3
  module AuthHelpers
4
- def log_in(email:, password:, remember_me: true)
5
- visit spree.login_path
4
+ def login_button
5
+ Spree.version.to_f == 4.1 ? Spree.t(:log_in) : Spree.t(:login)
6
+ end
7
+
8
+ def logout_button
9
+ Spree.version.to_f == 4.1 ? Spree.t('nav_bar.log_out') : Spree.t(:logout).upcase
10
+ end
11
+
12
+ def log_in(email:, password:, remember_me: true, locale: nil)
13
+ visit spree.login_path(locale: locale)
6
14
 
7
- fill_in 'Email', with: email
8
- fill_in 'Password', with: password
15
+ fill_in Spree.t(:email), with: email
16
+ fill_in Spree.t(:password), with: password
9
17
 
10
18
  # Regression test for #1257
11
- first('label', text: 'Remember me').click if remember_me
12
- click_button 'Log in'
19
+ first('label', text: Spree.t(:remember_me)).click if remember_me
20
+ click_button login_button
13
21
 
14
- expect(page).to have_content 'Logged in successfully'
22
+ expect(page).to have_content Spree.t(:logged_in_successfully)
15
23
  end
16
24
 
17
25
  def log_out
18
26
  show_user_menu
19
- click_link 'LOG OUT'
27
+ click_link logout_button
20
28
 
21
29
  expect(page).to have_content 'Signed out successfully'
22
30
  end
23
31
 
24
32
  def show_user_menu
25
- find("button[aria-label='Show user menu']").click
33
+ find("button[aria-label='#{Spree.t('nav_bar.show_user_menu')}']").click
26
34
  end
27
35
 
28
36
  def show_user_account
29
37
  within '#nav-bar' do
30
38
  show_user_menu
31
- click_link 'MY ACCOUNT'
39
+ click_link Spree.t(:my_account).upcase
32
40
  end
33
41
  end
34
42
  end
@@ -24,7 +24,7 @@
24
24
  <% end %>
25
25
  </div>
26
26
  <div class="col-lg-6 text-right">
27
- <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
27
+ <%= link_to Spree.t(:forgot_password), spree.admin_recover_password_path %>
28
28
  </div>
29
29
  </div>
30
30
  </div>
@@ -137,7 +137,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
137
137
  request.cookie_jar.signed[:guest_token] = 'ABC'
138
138
  request.cookie_jar.signed[:token] = 'DEF'
139
139
  end
140
-
140
+
141
141
  it 'assigns the correct token attribute for the order' do
142
142
  if Spree.version.to_f > 3.6
143
143
  order = create(:order, email: user.email, token: 'ABC', user_id: nil, created_by_id: nil)
@@ -157,6 +157,18 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
157
157
  post :create, params: { spree_user: { email: user.email, password: 'secret' }}
158
158
  expect(response).to redirect_to spree.account_path
159
159
  end
160
+
161
+ context 'different locale' do
162
+ before do
163
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr') if Spree.version.to_f >= 4.2
164
+ end
165
+
166
+ it 'redirects to localized account path after signing in' do
167
+ skip if Spree.version.to_f < 4.2
168
+ post :create, params: { spree_user: { email: user.email, password: 'secret' }, locale: 'fr' }
169
+ expect(response).to redirect_to spree.account_path(locale: 'fr')
170
+ end
171
+ end
160
172
  end
161
173
 
162
174
  context "and js format is used" do
@@ -25,7 +25,7 @@ RSpec.describe Spree::UsersController, type: :controller do
25
25
  it 'performs update' do
26
26
  put :update, params: { user: { email: 'mynew@email-address.com' } }
27
27
  expect(assigns[:user].email).to eq 'mynew@email-address.com'
28
- expect(response).to redirect_to spree.account_url(only_path: true)
28
+ expect(response).to redirect_to spree.account_path
29
29
  end
30
30
  end
31
31
 
@@ -10,7 +10,7 @@ RSpec.feature 'Accounts', type: :feature do
10
10
 
11
11
  fill_in 'Email', with: user.email
12
12
  fill_in 'Password', with: user.password
13
- click_button 'Log in'
13
+ click_button login_button
14
14
 
15
15
  show_user_account
16
16
  expect(page).to have_text 'admin@person.com'
@@ -43,7 +43,7 @@ RSpec.feature 'Accounts', type: :feature do
43
43
 
44
44
  fill_in 'Email', with: user.email
45
45
  fill_in 'Password', with: user.password
46
- click_button 'Log in'
46
+ click_button login_button
47
47
 
48
48
  show_user_account
49
49
  expect(page).to have_text 'email@person.com'
@@ -1,6 +1,7 @@
1
1
  RSpec.feature 'Admin orders', type: :feature do
2
2
  background do
3
- sign_in_as! create(:admin_user)
3
+ user = create(:admin_user)
4
+ log_in email: user.email, password: user.password
4
5
  end
5
6
 
6
7
  # Regression #203
@@ -15,7 +16,8 @@ RSpec.feature 'Admin orders', type: :feature do
15
16
 
16
17
  # Regression #203
17
18
  scenario 'can not edit orders' do
18
- expect { visit spree.edit_admin_order_path('nodata') }.to raise_error(ActiveRecord::RecordNotFound)
19
+ visit spree.edit_admin_order_path('nodata')
20
+ expect(page).to have_text('Order is not found')
19
21
  end
20
22
 
21
23
  # Regression #203
@@ -13,8 +13,8 @@ RSpec.feature 'Admin - Sign In', type: :feature do
13
13
  log_in(email: @user.email, password: 'secret')
14
14
  show_user_menu
15
15
 
16
- expect(page).not_to have_text 'Login'
17
- expect(page).to have_text 'LOG OUT'
16
+ expect(page).not_to have_text login_button.upcase
17
+ expect(page).to have_text logout_button.upcase
18
18
  expect(current_path).to eq '/account'
19
19
  end
20
20
 
@@ -33,9 +33,10 @@ RSpec.feature 'Admin - Sign In', type: :feature do
33
33
 
34
34
  fill_in 'Email', with: user.email
35
35
  fill_in 'Password', with: 'secret'
36
- click_button 'Log in'
36
+ click_button login_button
37
+
37
38
  if Spree.version.to_f > 4.1
38
- within '.navbar .dropdown-menu' do
39
+ within '.navbar .dropdown-menu-right' do
39
40
  expect(page).to have_text 'admin@person.com'
40
41
  end
41
42
  else
@@ -9,13 +9,13 @@ RSpec.feature 'Admin - Sign Out', type: :feature do
9
9
  fill_in 'Password', with: 'secret'
10
10
  # Regression test for #1257
11
11
  check 'Remember me'
12
- click_button 'Login'
12
+ click_button Spree.t(:login)
13
13
  end
14
14
 
15
15
  scenario 'allows a signed in user to logout', js: true do
16
16
  log_out
17
17
  visit spree.admin_login_path
18
- expect(page).to have_button 'Login'
19
- expect(page).not_to have_text 'Logout'
18
+ expect(page).to have_button Spree.t(:login)
19
+ expect(page).not_to have_text Spree.t(:logout)
20
20
  end
21
21
  end
@@ -7,7 +7,7 @@ RSpec.feature 'Admin Permissions', type: :feature do
7
7
 
8
8
  fill_in 'Email', with: user.email
9
9
  fill_in 'Password', with: user.password
10
- click_button 'Log in'
10
+ click_button login_button
11
11
  end
12
12
 
13
13
  context 'admin is restricted from accessing orders' do
@@ -55,7 +55,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
55
55
  visit spree.login_path
56
56
  fill_in 'Email', with: user.email
57
57
  fill_in 'Password', with: user.password
58
- click_button 'Log in'
58
+ click_button login_button
59
59
  expect(page).to have_text('Logged in successfully')
60
60
  find('a.cart-icon').click
61
61
 
@@ -89,7 +89,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
89
89
  token_url_regex = /^http:\/\/www.example.com\/user\/spree_user\/password\/edit\?reset_password_token=(.*)$/
90
90
  token = token_url_regex.match(reset_password_email.body.encoded)[1]
91
91
 
92
- visit spree.edit_spree_user_password_path(reset_password_token: token).tr("%0D","")
92
+ visit spree.edit_spree_user_password_path(reset_password_token: token.strip).tr("%0D","")
93
93
  fill_in 'Password', with: 'password'
94
94
  fill_in 'Password Confirmation', with: 'password'
95
95
  click_button 'Update'
@@ -1,13 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.feature 'Confirmation', type: :feature, reload_user: true do
3
+ RSpec.feature 'Confirmation', type: :feature, confirmable: true do
4
4
  before do
5
- set_confirmable_option(true)
6
5
  expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.current.id }).and_return(double(deliver: true))
7
6
  end
8
7
 
9
- after(:each) { set_confirmable_option(false) }
10
-
11
8
  background do
12
9
  ActionMailer::Base.default_url_options[:host] = 'http://example.com'
13
10
  end
@@ -17,7 +17,7 @@ RSpec.feature 'Orders', :js, type: :feature do
17
17
  visit spree.login_path
18
18
  fill_in 'Email', with: user.email
19
19
  fill_in 'Password', with: user.password
20
- click_button 'Log in'
20
+ click_button login_button
21
21
 
22
22
  visit spree.cart_path
23
23
  expect(page).to have_text 'RoR Mug'
@@ -29,7 +29,7 @@ RSpec.feature 'Orders', :js, type: :feature do
29
29
  visit spree.login_path
30
30
  fill_in 'Email', with: user.email
31
31
  fill_in 'Password', with: user.password
32
- click_button 'Log in'
32
+ click_button login_button
33
33
 
34
34
  # Order should have been merged with first session
35
35
  visit spree.cart_path
@@ -13,15 +13,15 @@ RSpec.feature 'Sign In', type: :feature do
13
13
  log_in(email: @user.email, password: @user.password)
14
14
  show_user_menu
15
15
 
16
- expect(page).not_to have_text 'Login'
17
- expect(page).to have_text 'LOG OUT'
16
+ expect(page).not_to have_text login_button.upcase
17
+ expect(page).to have_text logout_button.upcase
18
18
  expect(current_path).to eq '/account'
19
19
  end
20
20
 
21
21
  scenario 'show validation erros' do
22
22
  fill_in 'Email', with: @user.email
23
23
  fill_in 'Password', with: 'wrong_password'
24
- click_button 'Log in'
24
+ click_button login_button
25
25
 
26
26
  expect(page).to have_text 'Invalid email or password'
27
27
  expect(page).to have_text 'Log in'
@@ -33,13 +33,14 @@ RSpec.feature 'Sign In', type: :feature do
33
33
 
34
34
  fill_in 'Email', with: user.email
35
35
  fill_in 'Password', with: user.password
36
- click_button 'Log in'
37
36
 
38
37
  if Spree.version.to_f > 4.1
39
- within '.navbar .dropdown-menu' do
38
+ click_button login_button
39
+ within '.navbar .dropdown-menu-right' do
40
40
  expect(page).to have_text 'admin@person.com'
41
41
  end
42
42
  else
43
+ click_button login_button
43
44
  within '.user-menu' do
44
45
  expect(page).to have_text 'admin@person.com'
45
46
  end
@@ -51,7 +52,29 @@ RSpec.feature 'Sign In', type: :feature do
51
52
  visit spree.account_path
52
53
  fill_in 'Email', with: @user.email
53
54
  fill_in 'Password', with: @user.password
54
- click_button 'Log in'
55
+ click_button login_button
55
56
  expect(current_path).to eq '/account'
56
57
  end
58
+
59
+ context 'localized' do
60
+ before do
61
+ if Spree.version.to_f >= 4.2
62
+ add_french_locales
63
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
64
+ I18n.locale = :fr
65
+ end
66
+ end
67
+
68
+ after { I18n.locale = :en }
69
+
70
+ scenario 'let a user sign in successfully', js: true do
71
+ skip if Spree.version.to_f < 4.2
72
+ log_in(email: @user.email, password: @user.password, locale: 'fr')
73
+ show_user_menu
74
+
75
+ expect(page).not_to have_text Spree.t(:login).upcase
76
+ expect(page).to have_text Spree.t(:logout).upcase
77
+ expect(current_url).to match(/\/account\?locale\=fr$/)
78
+ end
79
+ end
57
80
  end
@@ -16,8 +16,8 @@ RSpec.feature 'Sign Out', type: :feature, js: true do
16
16
  visit spree.root_path
17
17
  show_user_menu
18
18
 
19
- expect(page).to have_link 'LOG IN'
20
- expect(page).not_to have_link 'LOG OUT'
19
+ expect(page).to have_link login_button.upcase
20
+ expect(page).not_to have_link logout_button.upcase
21
21
  end
22
22
 
23
23
  describe 'before_logout' do
@@ -27,6 +27,33 @@ RSpec.describe Spree::User, type: :model do
27
27
  end
28
28
  end
29
29
 
30
+ describe 'validations' do
31
+ context 'email' do
32
+ let(:user) { build(:user, email: nil) }
33
+
34
+ it 'cannot be empty' do
35
+ expect(user.valid?).to be false
36
+ expect(user.errors.messages[:email].first).to eq "can't be blank"
37
+ end
38
+ end
39
+
40
+ context 'password' do
41
+ let(:user) { build(:user, password_confirmation: nil) }
42
+
43
+ it 'password confirmation cannot be empty' do
44
+ expect(user.valid?).to be false
45
+ expect(user.errors.messages[:password_confirmation].first).to eq "doesn't match Password"
46
+ end
47
+
48
+ let(:user) { build(:user, password: 'pass1234', password_confirmation: 'pass') }
49
+
50
+ it 'passwords has to be equal to password confirmation' do
51
+ expect(user.valid?).to be false
52
+ expect(user.errors.messages[:password_confirmation].first).to eq "doesn't match Password"
53
+ end
54
+ end
55
+ end
56
+
30
57
  context '#destroy' do
31
58
  it 'will soft delete with uncompleted orders' do
32
59
  order = build(:order)
@@ -65,17 +92,48 @@ RSpec.describe Spree::User, type: :model do
65
92
  end
66
93
  end
67
94
 
68
- describe "confirmable", reload_user: true do
69
- it "is confirmable if the confirmable option is enabled" do
70
- set_confirmable_option(true)
95
+ describe "confirmable" do
96
+ it "is confirmable if the confirmable option is enabled", confirmable: true do
71
97
  Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.current.id }).and_return(double(deliver: true))
72
98
  expect(Spree.user_class.devise_modules).to include(:confirmable)
73
- set_confirmable_option(false)
74
99
  end
75
100
 
76
- it "is not confirmable if the confirmable option is disabled" do
77
- set_confirmable_option(false)
78
- expect(Spree.user_class.devise_modules).to_not include(:confirmable)
101
+ it "is not confirmable if the confirmable option is disabled", confirmable: false do
102
+ expect(Spree.user_class.devise_modules).not_to include(:confirmable)
103
+ end
104
+ end
105
+
106
+ describe "#send_confirmation_instructions", retry: 2 do
107
+ let(:default_store) { Spree::Store.default }
108
+
109
+ context "when current store not exists" do
110
+ it 'takes default store and sends confirmation instruction', confirmable: true do
111
+ user = Spree.user_class.new
112
+ user.email = FFaker::Internet.email
113
+ user.password = user.password_confirmation = 'pass1234'
114
+ user.save
115
+
116
+ expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
117
+ user, anything, { current_store_id: default_store.id }).and_return(double(deliver: true)
118
+ )
119
+
120
+ user.send_confirmation_instructions(nil)
121
+ end
122
+ end
123
+
124
+ context "when current store exists" do
125
+ it 'takes current store and sends confirmation instruction', confirmable: true do
126
+ user = Spree.user_class.new
127
+ user.email = FFaker::Internet.email
128
+ user.password = user.password_confirmation = 'pass1234'
129
+ user.save
130
+
131
+ expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
132
+ user, anything, { current_store_id: store.id }).and_return(double(deliver: true)
133
+ )
134
+
135
+ user.send_confirmation_instructions(store)
136
+ end
79
137
  end
80
138
  end
81
139
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.feature 'User update', type: :request do
4
+ context 'CSRF protection' do
5
+ %i[exception reset_session null_session].each do |strategy|
6
+ # Completely clean the configuration of forgery protection for the
7
+ # controller and reset it after the expectations. However, besides `:with`,
8
+ # the options given to `protect_from_forgery` are processed on the fly.
9
+ # I.e., there's no way to retain them. The initial setup corresponds to the
10
+ # dummy application, which uses the default Rails skeleton in that regard.
11
+ # So, if at some point Rails changed the given options, we should update it
12
+ # here.
13
+ around do |example|
14
+ controller = Spree::UsersController
15
+ old_allow_forgery_protection_value = controller.allow_forgery_protection
16
+ old_forgery_protection_strategy = controller.forgery_protection_strategy
17
+ controller.skip_forgery_protection
18
+ controller.allow_forgery_protection = true
19
+ controller.protect_from_forgery with: strategy
20
+
21
+ example.run
22
+
23
+ controller.allow_forgery_protection = old_allow_forgery_protection_value
24
+ controller.forgery_protection_strategy = old_forgery_protection_strategy
25
+ end
26
+
27
+ it "is not possible to take account over with the #{strategy} forgery protection strategy" do
28
+ user = create(:user, email: 'legit@mail.com', password: 'password')
29
+
30
+ post '/login', params: "spree_user[email]=legit@mail.com&spree_user[password]=password"
31
+ begin
32
+ put '/users/123456', params: 'user[email]=hacked@example.com'
33
+ rescue
34
+ # testing that the account is not compromised regardless of any raised
35
+ # exception
36
+ end
37
+
38
+ expect(user.reload.email).to eq('legit@mail.com')
39
+ end
40
+ end
41
+ end
42
+ end
data/spec/spec_helper.rb CHANGED
@@ -9,10 +9,14 @@ require 'spree_dev_tools/rspec/spec_helper'
9
9
  # in spec/support/ and its subdirectories.
10
10
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
11
11
 
12
+ require 'spree/testing_support/locale_helpers' if Spree.version.to_f >= 4.2
13
+
12
14
  RSpec.configure do |config|
13
15
  config.before(:each) do
14
16
  allow(RSpec::Rails::ViewRendering::EmptyTemplateHandler)
15
17
  .to receive(:call)
16
18
  .and_return(%("")) if Rails.gem_version >= Gem::Version.new('6.0.0.beta1')
17
19
  end
20
+
21
+ config.include Spree::TestingSupport::LocaleHelpers if defined?(Spree::TestingSupport::LocaleHelpers)
18
22
  end
@@ -1,11 +1,25 @@
1
- module ConfirmHelpers
2
- def set_confirmable_option(value)
3
- Spree::Auth::Config[:confirmable] = value
4
- Spree.send(:remove_const, 'User')
5
- load File.expand_path("../../../app/models/spree/user.rb", __FILE__)
1
+ RSpec.configure do |config|
2
+ config.around do |example|
3
+ if example.metadata.key?(:confirmable)
4
+ old_user = Spree::User
5
+
6
+ begin
7
+ example.run
8
+ ensure
9
+ Spree.const_set('User', old_user)
10
+ end
11
+ else
12
+ example.run
13
+ end
6
14
  end
7
- end
8
15
 
9
- RSpec.configure do |c|
10
- c.include ConfirmHelpers
16
+ config.before do |example|
17
+ if example.metadata.key?(:confirmable)
18
+ Rails.cache.clear
19
+ Spree::Auth::Config[:confirmable] = example.metadata[:confirmable]
20
+
21
+ Spree.send(:remove_const, :User)
22
+ load File.expand_path('../../../app/models/spree/user.rb', __FILE__)
23
+ end
24
+ end
11
25
  end
@@ -1,9 +1,13 @@
1
1
  # encoding: UTF-8
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'spree/auth/version'
2
6
 
3
7
  Gem::Specification.new do |s|
4
8
  s.platform = Gem::Platform::RUBY
5
9
  s.name = 'spree_auth_devise'
6
- s.version = '4.3.2'
10
+ s.version = Spree::Auth::VERSION
7
11
  s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.'
8
12
  s.description = s.summary
9
13
 
@@ -29,7 +33,7 @@ Gem::Specification.new do |s|
29
33
  s.add_dependency 'devise', '~> 4.7'
30
34
  s.add_dependency 'devise-encryptable', '0.2.0'
31
35
 
32
- spree_version = '>= 4.1', '< 5.0'
36
+ spree_version = '>= 4.3.0.rc1'
33
37
  s.add_dependency 'spree_core', spree_version
34
38
  s.add_dependency 'spree_extension'
35
39
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.2
4
+ version: 4.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  - Spark Solutions
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-25 00:00:00.000000000 Z
12
+ date: 2021-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -45,20 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '4.1'
49
- - - "<"
50
- - !ruby/object:Gem::Version
51
- version: '5.0'
48
+ version: 4.3.0.rc1
52
49
  type: :runtime
53
50
  prerelease: false
54
51
  version_requirements: !ruby/object:Gem::Requirement
55
52
  requirements:
56
53
  - - ">="
57
54
  - !ruby/object:Gem::Version
58
- version: '4.1'
59
- - - "<"
60
- - !ruby/object:Gem::Version
61
- version: '5.0'
55
+ version: 4.3.0.rc1
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: spree_extension
64
58
  requirement: !ruby/object:Gem::Requirement
@@ -95,10 +89,11 @@ extensions: []
95
89
  extra_rdoc_files: []
96
90
  files:
97
91
  - ".circleci/config.yml"
92
+ - ".gem_release.yml"
93
+ - ".github/dependabot.yml"
98
94
  - ".gitignore"
99
95
  - ".rspec"
100
96
  - ".travis.yml"
101
- - Appraisals
102
97
  - CHANGELOG.md
103
98
  - Gemfile
104
99
  - LICENSE.md
@@ -107,23 +102,13 @@ files:
107
102
  - app/controllers/metal_decorator.rb
108
103
  - app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb
109
104
  - app/controllers/spree/api/v2/storefront/passwords_controller.rb
110
- - app/controllers/spree/user_confirmations_controller.rb
111
- - app/controllers/spree/user_passwords_controller.rb
112
- - app/controllers/spree/user_registrations_controller.rb
113
- - app/controllers/spree/user_sessions_controller.rb
114
105
  - app/mailers/spree/user_mailer.rb
115
106
  - app/models/spree/auth_configuration.rb
116
107
  - app/models/spree/user.rb
117
- - app/services/spree/account/create.rb
118
- - app/services/spree/account/update.rb
119
108
  - app/views/spree/user_mailer/confirmation_instructions.html.erb
120
109
  - app/views/spree/user_mailer/confirmation_instructions.text.erb
121
110
  - app/views/spree/user_mailer/reset_password_instructions.html.erb
122
111
  - app/views/spree/user_mailer/reset_password_instructions.text.erb
123
- - app/views/spree/user_passwords/edit.html.erb
124
- - app/views/spree/user_passwords/new.html.erb
125
- - app/views/spree/user_registrations/new.html.erb
126
- - app/views/spree/user_sessions/new.html.erb
127
112
  - bin/rails
128
113
  - config.ru
129
114
  - config/initializers/devise.rb
@@ -149,10 +134,8 @@ files:
149
134
  - db/migrate/20140904000425_add_deleted_at_to_users.rb
150
135
  - db/migrate/20141002154641_add_confirmable_to_users.rb
151
136
  - db/migrate/20150416152553_add_missing_indices_on_user.rb
137
+ - db/migrate/20210728103922_change_type_of_ship_address_id_and_bill_address_id_for_spree_users.rb
152
138
  - db/seeds.rb
153
- - gemfiles/spree_4_1.gemfile
154
- - gemfiles/spree_master.gemfile
155
- - lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb
156
139
  - lib/controllers/backend/spree/admin/base_controller_decorator.rb
157
140
  - lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb
158
141
  - lib/controllers/backend/spree/admin/orders_controller_decorator.rb
@@ -160,12 +143,17 @@ files:
160
143
  - lib/controllers/backend/spree/admin/user_passwords_controller.rb
161
144
  - lib/controllers/backend/spree/admin/user_sessions_controller.rb
162
145
  - lib/controllers/frontend/spree/checkout_controller_decorator.rb
146
+ - lib/controllers/frontend/spree/user_confirmations_controller.rb
147
+ - lib/controllers/frontend/spree/user_passwords_controller.rb
148
+ - lib/controllers/frontend/spree/user_registrations_controller.rb
149
+ - lib/controllers/frontend/spree/user_sessions_controller.rb
163
150
  - lib/controllers/frontend/spree/users_controller.rb
164
151
  - lib/generators/spree/auth/install/install_generator.rb
165
152
  - lib/generators/spree/auth/install/templates/config/initializers/devise.rb
166
153
  - lib/spree/auth.rb
167
154
  - lib/spree/auth/devise.rb
168
155
  - lib/spree/auth/engine.rb
156
+ - lib/spree/auth/version.rb
169
157
  - lib/spree/authentication_helpers.rb
170
158
  - lib/spree/testing_support/auth_helpers.rb
171
159
  - lib/spree/testing_support/checkout_helpers.rb
@@ -179,6 +167,10 @@ files:
179
167
  - lib/views/backend/spree/layouts/login.html.erb
180
168
  - lib/views/frontend/spree/shared/_flashes.html.erb
181
169
  - lib/views/frontend/spree/shared/_login_bar.html.erb
170
+ - lib/views/frontend/spree/user_passwords/edit.html.erb
171
+ - lib/views/frontend/spree/user_passwords/new.html.erb
172
+ - lib/views/frontend/spree/user_registrations/new.html.erb
173
+ - lib/views/frontend/spree/user_sessions/new.html.erb
182
174
  - spec/controllers/spree/admin/orders_controller_spec.rb
183
175
  - spec/controllers/spree/admin/user_sessions_controller_spec.rb
184
176
  - spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb
@@ -209,22 +201,22 @@ files:
209
201
  - spec/models/user_spec.rb
210
202
  - spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb
211
203
  - spec/requests/spree/api/v2/storefront/account_spec.rb
204
+ - spec/requests/spree/frontend/user_update_spec.rb
212
205
  - spec/spec_helper.rb
213
206
  - spec/support/ability.rb
214
207
  - spec/support/configuration_helpers.rb
215
208
  - spec/support/confirm_helpers.rb
216
209
  - spec/support/email.rb
217
- - spec/support/user_helper.rb
218
210
  - spree_auth_devise.gemspec
219
211
  homepage: https://spreecommerce.org
220
212
  licenses:
221
213
  - BSD-3-Clause
222
214
  metadata:
223
215
  bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
224
- changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.3.2
216
+ changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.4.1
225
217
  documentation_uri: https://guides.spreecommerce.org/
226
- source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.3.2
227
- post_install_message:
218
+ source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.4.1
219
+ post_install_message:
228
220
  rdoc_options: []
229
221
  require_paths:
230
222
  - lib
@@ -240,8 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
232
  version: '0'
241
233
  requirements:
242
234
  - none
243
- rubygems_version: 3.0.3
244
- signing_key:
235
+ rubygems_version: 3.2.3
236
+ signing_key:
245
237
  specification_version: 4
246
238
  summary: Provides authentication and authorization services for use with Spree by
247
239
  using Devise and CanCan.
@@ -276,9 +268,9 @@ test_files:
276
268
  - spec/models/user_spec.rb
277
269
  - spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb
278
270
  - spec/requests/spree/api/v2/storefront/account_spec.rb
271
+ - spec/requests/spree/frontend/user_update_spec.rb
279
272
  - spec/spec_helper.rb
280
273
  - spec/support/ability.rb
281
274
  - spec/support/configuration_helpers.rb
282
275
  - spec/support/confirm_helpers.rb
283
276
  - spec/support/email.rb
284
- - spec/support/user_helper.rb
data/Appraisals DELETED
@@ -1,9 +0,0 @@
1
- appraise 'spree-4-1' do
2
- gem 'rails-controller-testing'
3
- gem 'spree', '~> 4.1'
4
- end
5
-
6
- appraise 'spree-master' do
7
- gem 'rails-controller-testing'
8
- gem 'spree', github: 'spree/spree', branch: 'master'
9
- end
@@ -1,19 +0,0 @@
1
- module Spree
2
- module Account
3
- class Create
4
- prepend Spree::ServiceModule::Base
5
-
6
- def call(user_params: nil)
7
- user_params ||= {}
8
-
9
- user = Spree.user_class.new(user_params)
10
-
11
- if user.save
12
- success(user)
13
- else
14
- failure(user)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- module Spree
2
- module Account
3
- class Update
4
- prepend Spree::ServiceModule::Base
5
-
6
- def call(user:, user_params: nil)
7
- user_params ||= {}
8
-
9
- if user.update(user_params)
10
- success(user)
11
- else
12
- failure(user)
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails-controller-testing"
6
- gem "spree", "~> 4.1"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails-controller-testing"
6
- gem "spree", github: "spree/spree", branch: "master"
7
-
8
- gemspec path: "../"
@@ -1,41 +0,0 @@
1
- module Spree
2
- module Api
3
- module V2
4
- module Storefront
5
- module AccountControllerDecorator
6
- def self.prepended(base)
7
- base.skip_before_action :require_spree_current_user, only: [:create]
8
- end
9
-
10
- def create
11
- result = Spree::Account::Create.call(user_params: spree_user_params)
12
-
13
- render_payload(result)
14
- end
15
-
16
- def update
17
- result = Spree::Account::Update.call(user: spree_current_user, user_params: spree_user_params)
18
-
19
- render_payload(result)
20
- end
21
-
22
- private
23
-
24
- def render_payload(result)
25
- if result.success?
26
- render_serialized_payload { serialize_resource(result.value) }
27
- else
28
- render_error_payload(result.error)
29
- end
30
- end
31
-
32
- def spree_user_params
33
- params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
41
- ::Spree::Api::V2::Storefront::AccountController.prepend(Spree::Api::V2::Storefront::AccountControllerDecorator)
@@ -1,11 +0,0 @@
1
- RSpec.configure do |config|
2
- # allows to keep user const after reload
3
- config.around :each, :reload_user do |example|
4
- old_user = Spree::User
5
-
6
- example.run
7
-
8
- Spree.send(:remove_const, 'User')
9
- Spree.const_set('User', old_user)
10
- end
11
- end