spree_auth_devise 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gem_release.yml +2 -0
- data/.github/dependabot.yml +11 -0
- data/.travis.yml +1 -11
- data/Gemfile +5 -1
- data/README.md +1 -1
- data/app/mailers/spree/user_mailer.rb +4 -4
- data/app/models/spree/user.rb +5 -1
- data/config/initializers/warden.rb +1 -1
- data/config/routes.rb +3 -1
- data/db/migrate/20210728103922_change_type_of_ship_address_id_and_bill_address_id_for_spree_users.rb +8 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +17 -1
- data/{app/controllers → lib/controllers/frontend}/spree/user_confirmations_controller.rb +11 -0
- data/{app/controllers → lib/controllers/frontend}/spree/user_passwords_controller.rb +10 -3
- data/{app/controllers → lib/controllers/frontend}/spree/user_registrations_controller.rb +10 -3
- data/{app/controllers → lib/controllers/frontend}/spree/user_sessions_controller.rb +13 -6
- data/lib/controllers/frontend/spree/users_controller.rb +2 -2
- data/lib/spree/auth/engine.rb +1 -9
- data/lib/spree/auth/version.rb +9 -0
- data/lib/spree/testing_support/auth_helpers.rb +18 -10
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
- data/{app/views → lib/views/frontend}/spree/user_passwords/edit.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/user_passwords/new.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/user_registrations/new.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/user_sessions/new.html.erb +0 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +13 -1
- data/spec/controllers/spree/users_controller_spec.rb +1 -1
- data/spec/features/account_spec.rb +2 -2
- data/spec/features/admin/orders_spec.rb +4 -2
- data/spec/features/admin/sign_in_spec.rb +5 -4
- data/spec/features/admin/sign_out_spec.rb +3 -3
- data/spec/features/admin_permissions_spec.rb +1 -1
- data/spec/features/checkout_spec.rb +2 -2
- data/spec/features/confirmation_spec.rb +1 -4
- data/spec/features/order_spec.rb +2 -2
- data/spec/features/sign_in_spec.rb +29 -6
- data/spec/features/sign_out_spec.rb +2 -2
- data/spec/models/user_spec.rb +65 -7
- data/spec/spec_helper.rb +4 -0
- data/spec/support/confirm_helpers.rb +22 -8
- data/spree_auth_devise.gemspec +6 -2
- metadata +18 -28
- data/Appraisals +0 -9
- data/app/services/spree/account/create.rb +0 -19
- data/app/services/spree/account/update.rb +0 -17
- data/gemfiles/spree_4_1.gemfile +0 -8
- data/gemfiles/spree_master.gemfile +0 -8
- data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +0 -41
- data/spec/support/user_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce7d97d09c213c428ce6ce21c81a2156cfa2dfd0e7373effda3980a6e4730dc
|
4
|
+
data.tar.gz: c5ab728a3019fe0117c9c6b0fb62d962092cb019ff81e861258daa0c26927537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce33276ffcce416fb378d8c9e3fdae88efeec6166520e97304b8520263a667f2714d46ff724eacf004c34defbb876517979482824bd18e2ef2667c3b56f83b9
|
7
|
+
data.tar.gz: fd9b8eb25d08f6e98939d66a0a9b432452404a5d1ebf21572552ec611bfd11241cde424a910a02373f935cd8cdabd2259783f3c63019209fde2b0daafaafce21
|
data/.gem_release.yml
ADDED
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: '
|
4
|
+
gem 'spree', github: 'spree/spree', branch: 'main'
|
5
|
+
gem 'spree_backend', github: 'spree/spree', branch: 'main'
|
6
|
+
gem 'spree_frontend', github: 'spree/spree', branch: 'main'
|
7
|
+
gem 'spree_emails', github: 'spree/spree', branch: 'main'
|
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.
|
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:
|
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 =
|
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:
|
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
|
data/app/models/spree/user.rb
CHANGED
@@ -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
|
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
|
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
|
|
@@ -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(:
|
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,6 +6,17 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
6
6
|
include Spree::Core::ControllerHelpers::Order
|
7
7
|
include Spree::Core::ControllerHelpers::Store
|
8
8
|
|
9
|
+
include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
|
10
|
+
|
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)
|
19
|
+
|
9
20
|
before_action :set_current_order
|
10
21
|
|
11
22
|
if Spree.version.to_f >= 4.2
|
@@ -6,9 +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?(SpreeI18n::ControllerLocaleHelper)
|
10
|
-
|
11
|
-
|
9
|
+
include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
|
10
|
+
|
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)
|
12
19
|
|
13
20
|
before_action :set_current_order
|
14
21
|
|
@@ -6,9 +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?(SpreeI18n::ControllerLocaleHelper)
|
10
|
-
|
11
|
-
|
9
|
+
include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
|
10
|
+
|
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)
|
12
19
|
|
13
20
|
before_action :check_permissions, only: [:edit, :update]
|
14
21
|
before_action :set_current_order
|
@@ -6,9 +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?(SpreeI18n::ControllerLocaleHelper)
|
10
|
-
|
11
|
-
|
9
|
+
include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
|
10
|
+
|
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)
|
12
19
|
|
13
20
|
before_action :set_current_order
|
14
21
|
|
@@ -18,7 +25,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
18
25
|
if spree_user_signed_in?
|
19
26
|
respond_to do |format|
|
20
27
|
format.html {
|
21
|
-
flash[:success] = Spree.t(:
|
28
|
+
flash[:success] = Spree.t(:logged_in_successfully)
|
22
29
|
redirect_back_or_default(after_sign_in_redirect(spree_current_user))
|
23
30
|
}
|
24
31
|
format.js {
|
@@ -58,7 +65,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
58
65
|
end
|
59
66
|
|
60
67
|
def after_sign_in_redirect(resource_or_scope)
|
61
|
-
stored_location_for(resource_or_scope) || account_path
|
68
|
+
stored_location_for(resource_or_scope) || spree.account_path
|
62
69
|
end
|
63
70
|
|
64
71
|
def respond_to_on_destroy
|
@@ -74,6 +81,6 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
74
81
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
75
82
|
router_name = Devise.mappings[scope].router_name
|
76
83
|
context = router_name ? send(router_name) : self
|
77
|
-
context.respond_to?(:login_path) ? context.login_path :
|
84
|
+
context.respond_to?(:login_path) ? context.login_path : spree.root_path
|
78
85
|
end
|
79
86
|
end
|
@@ -6,7 +6,7 @@ class Spree::UsersController < Spree::StoreController
|
|
6
6
|
include Spree::Core::ControllerHelpers
|
7
7
|
|
8
8
|
def show
|
9
|
-
@orders = @user.orders.complete.order('completed_at desc')
|
9
|
+
@orders = @user.orders.for_store(current_store).complete.order('completed_at desc')
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
@@ -34,7 +34,7 @@ class Spree::UsersController < Spree::StoreController
|
|
34
34
|
bypass_sign_in(@user)
|
35
35
|
end
|
36
36
|
end
|
37
|
-
redirect_to spree.
|
37
|
+
redirect_to spree.account_path, notice: Spree.t(:account_updated)
|
38
38
|
else
|
39
39
|
render :edit
|
40
40
|
end
|
data/lib/spree/auth/engine.rb
CHANGED
@@ -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 =
|
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
|
@@ -1,34 +1,42 @@
|
|
1
1
|
module Spree
|
2
2
|
module TestingSupport
|
3
3
|
module AuthHelpers
|
4
|
-
def
|
5
|
-
|
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
|
8
|
-
fill_in
|
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:
|
12
|
-
click_button
|
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
|
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
|
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='
|
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
|
39
|
+
click_link Spree.t(:my_account).upcase
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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.
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
17
|
-
expect(page).to have_text
|
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
|
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
|
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
|
19
|
-
expect(page).not_to have_text
|
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
|
@@ -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
|
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,
|
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
|
data/spec/features/order_spec.rb
CHANGED
@@ -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
|
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
|
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
|
17
|
-
expect(page).to have_text
|
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
|
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
|
-
|
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
|
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
|
20
|
-
expect(page).not_to have_link
|
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
|
data/spec/models/user_spec.rb
CHANGED
@@ -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"
|
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
|
-
|
78
|
-
|
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
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
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
|
data/spree_auth_devise.gemspec
CHANGED
@@ -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 =
|
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.
|
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,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
|
+
version: 4.4.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
|
+
date: 2021-09-14 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:
|
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:
|
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
|
@@ -214,16 +206,15 @@ files:
|
|
214
206
|
- spec/support/configuration_helpers.rb
|
215
207
|
- spec/support/confirm_helpers.rb
|
216
208
|
- spec/support/email.rb
|
217
|
-
- spec/support/user_helper.rb
|
218
209
|
- spree_auth_devise.gemspec
|
219
210
|
homepage: https://spreecommerce.org
|
220
211
|
licenses:
|
221
212
|
- BSD-3-Clause
|
222
213
|
metadata:
|
223
214
|
bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
|
224
|
-
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.
|
215
|
+
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.4.0
|
225
216
|
documentation_uri: https://guides.spreecommerce.org/
|
226
|
-
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.
|
217
|
+
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.4.0
|
227
218
|
post_install_message:
|
228
219
|
rdoc_options: []
|
229
220
|
require_paths:
|
@@ -281,4 +272,3 @@ test_files:
|
|
281
272
|
- spec/support/configuration_helpers.rb
|
282
273
|
- spec/support/confirm_helpers.rb
|
283
274
|
- spec/support/email.rb
|
284
|
-
- spec/support/user_helper.rb
|
data/Appraisals
DELETED
@@ -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
|
data/gemfiles/spree_4_1.gemfile
DELETED
@@ -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)
|
data/spec/support/user_helper.rb
DELETED