spree_auth_devise 4.4.2 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +14 -73
- data/Gemfile +8 -1
- data/README.md +5 -11
- data/config/initializers/devise.rb +1 -1
- data/config/routes.rb +47 -45
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +1 -1
- data/lib/controllers/backend/spree/{admin → auth/admin}/base_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders/customer_details_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb +6 -0
- data/lib/controllers/frontend/spree/{checkout_controller_decorator.rb → auth/checkout_controller_decorator.rb} +4 -4
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +2 -2
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +5 -3
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +2 -2
- data/lib/mailers/spree/user_mailer.rb +38 -0
- data/lib/spree/auth/configuration.rb +33 -0
- data/lib/spree/auth/engine.rb +14 -3
- data/lib/spree/auth/version.rb +1 -1
- data/lib/spree/authentication_helpers.rb +6 -6
- data/lib/spree/testing_support/auth_helpers.rb +8 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +17 -15
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +13 -13
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +8 -9
- data/lib/views/backend/spree/layouts/login.html.erb +1 -1
- data/lib/views/frontend/spree/user_registrations/new.html.erb +1 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +2 -2
- data/spec/controllers/spree/checkout_controller_spec.rb +34 -2
- data/spec/controllers/spree/products_controller_spec.rb +1 -0
- data/spec/controllers/spree/user_registrations_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +18 -0
- data/spec/controllers/spree/users_controller_spec.rb +39 -5
- data/spec/features/account_spec.rb +1 -0
- data/spec/features/admin/sign_in_spec.rb +20 -1
- data/spec/features/checkout_spec.rb +5 -4
- data/spec/features/confirmation_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +2 -2
- data/spec/mailers/user_mailer_spec.rb +3 -3
- data/spec/models/user_spec.rb +3 -3
- data/spec/support/configuration_helpers.rb +1 -1
- data/spec/support/confirm_helpers.rb +3 -1
- data/spree_auth_devise.gemspec +1 -1
- metadata +18 -18
- data/app/mailers/spree/user_mailer.rb +0 -23
- data/app/models/spree/auth_configuration.rb +0 -8
- data/lib/controllers/backend/spree/admin/resource_controller_decorator.rb +0 -6
- /data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.html.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.text.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.html.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.text.erb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1bc8fb18988dfe1cc0e8f65220f824ce8553236a265add61e9530d11fe6c7c
|
4
|
+
data.tar.gz: 369edc99327bb03195a2c07007c9817c47036033db071b4c65da4567fa212505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8a5ab6f8ccc9d79f8a7767d213f08ef5e60fdb7c6b77640f2ef2719432a695de5bd64e480e818f444a16ca480d1daf45d524dbe1521405e7eab67e97e948791
|
7
|
+
data.tar.gz: 0ed79a471adfb6ff76d1d12a5302a6355e14362dd9318278c0810e2b7ddfc3e102b31c17f22b0d227ada3c9affdc7b8dbac264a52a295e158b1f15594f862b68
|
data/.circleci/config.yml
CHANGED
@@ -9,55 +9,23 @@ defaults: &defaults
|
|
9
9
|
BUNDLE_PATH: ~/spree/vendor/bundle
|
10
10
|
working_directory: ~/spree
|
11
11
|
docker:
|
12
|
-
- image: &ruby_image circleci/ruby:
|
12
|
+
- image: &ruby_image circleci/ruby:3.0-node-browsers
|
13
13
|
- image: &redis_image circleci/redis:6.2-alpine
|
14
14
|
|
15
|
-
defaults_3_0: &defaults_3_0
|
16
|
-
<<: *defaults
|
17
|
-
docker:
|
18
|
-
- image: &ruby_3_0_image circleci/ruby:3.0-node-browsers
|
19
|
-
- image: *redis_image
|
20
|
-
|
21
15
|
run_tests: &run_tests
|
22
16
|
<<: *defaults
|
23
|
-
steps:
|
24
|
-
- checkout
|
25
|
-
- restore_cache:
|
26
|
-
keys:
|
27
|
-
- spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
|
28
|
-
- spree-auth-devise-bundle-v9-ruby-2-7
|
29
|
-
- run:
|
30
|
-
name: Set bundle path
|
31
|
-
command: bundle config --local path vendor/bundle
|
32
|
-
- run:
|
33
|
-
name: Ensure bundle Install
|
34
|
-
command: |
|
35
|
-
bundle check || bundle install
|
36
|
-
- run:
|
37
|
-
name: Create test app
|
38
|
-
command: |
|
39
|
-
bundle exec rake test_app
|
40
|
-
- run:
|
41
|
-
name: Run Rspec
|
42
|
-
command: |
|
43
|
-
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
44
|
-
bundle exec rspec --format documentation \
|
45
|
-
--format RspecJunitFormatter \
|
46
|
-
-o ~/rspec/rspec.xml \
|
47
|
-
-- ${TESTFILES}
|
48
|
-
- store_test_results:
|
49
|
-
path: ~/rspec
|
50
|
-
- store_artifacts:
|
51
|
-
path: tmp/capybara
|
52
|
-
|
53
|
-
run_tests_3_0: &run_tests_3_0
|
54
|
-
<<: *defaults_3_0
|
55
17
|
steps:
|
56
18
|
- checkout
|
57
19
|
- restore_cache:
|
58
20
|
keys:
|
59
21
|
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
60
22
|
- spree-auth-devise-bundle-v9-ruby-3-0
|
23
|
+
- run:
|
24
|
+
name: Add keyserver
|
25
|
+
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
|
26
|
+
- run:
|
27
|
+
name: Install libvips
|
28
|
+
command: sudo apt-get update && sudo apt-get install libvips
|
61
29
|
- run:
|
62
30
|
name: Set bundle path
|
63
31
|
command: bundle config --local path vendor/bundle
|
@@ -85,32 +53,18 @@ run_tests_3_0: &run_tests_3_0
|
|
85
53
|
jobs:
|
86
54
|
bundle:
|
87
55
|
<<: *defaults
|
88
|
-
steps:
|
89
|
-
- checkout
|
90
|
-
- restore_cache:
|
91
|
-
keys:
|
92
|
-
- spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
|
93
|
-
- spree-auth-devise-bundle-v9-ruby-2-7
|
94
|
-
- run:
|
95
|
-
name: Set bundle path
|
96
|
-
command: bundle config --local path vendor/bundle
|
97
|
-
- run:
|
98
|
-
name: Bundle Install
|
99
|
-
command: |
|
100
|
-
bundle check || bundle install
|
101
|
-
- save_cache:
|
102
|
-
paths:
|
103
|
-
- vendor/bundle
|
104
|
-
key: spree-auth-devise-bundle-v9-ruby-2-7-{{ checksum "Gemfile.lock" }}
|
105
|
-
|
106
|
-
bundle_ruby_3_0:
|
107
|
-
<<: *defaults_3_0
|
108
56
|
steps:
|
109
57
|
- checkout
|
110
58
|
- restore_cache:
|
111
59
|
keys:
|
112
60
|
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
113
61
|
- spree-auth-devise-bundle-v9-ruby-3-0
|
62
|
+
- run:
|
63
|
+
name: Add keyserver
|
64
|
+
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
|
65
|
+
- run:
|
66
|
+
name: Install libvips
|
67
|
+
command: sudo apt-get update && sudo apt-get install libvips
|
114
68
|
- run:
|
115
69
|
name: Set bundle path
|
116
70
|
command: bundle config --local path vendor/bundle
|
@@ -137,15 +91,6 @@ jobs:
|
|
137
91
|
environment:
|
138
92
|
POSTGRES_USER: postgres
|
139
93
|
|
140
|
-
tests_postgres_ruby_3_0: &tests_postgres_ruby_3_0
|
141
|
-
<<: *run_tests_3_0
|
142
|
-
environment:
|
143
|
-
<<: *postgres_environment
|
144
|
-
docker:
|
145
|
-
- image: *ruby_3_0_image
|
146
|
-
- image: *postgres_image
|
147
|
-
- image: *redis_image
|
148
|
-
|
149
94
|
tests_mysql: &tests_mysql
|
150
95
|
<<: *run_tests
|
151
96
|
environment: &mysql_environment
|
@@ -165,13 +110,9 @@ workflows:
|
|
165
110
|
main:
|
166
111
|
jobs:
|
167
112
|
- bundle
|
168
|
-
- bundle_ruby_3_0
|
169
113
|
- tests_postgres:
|
170
114
|
requires:
|
171
115
|
- bundle
|
172
|
-
- tests_postgres_ruby_3_0:
|
173
|
-
requires:
|
174
|
-
- bundle_ruby_3_0
|
175
116
|
- tests_mysql:
|
176
117
|
requires:
|
177
|
-
- bundle
|
118
|
+
- bundle
|
data/Gemfile
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rails-controller-testing'
|
4
|
+
gem 'devise', github: 'heartcombo/devise', branch: 'main'
|
4
5
|
gem 'spree', github: 'spree/spree', branch: 'main'
|
5
6
|
gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
|
6
|
-
gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
|
7
7
|
gem 'spree_emails', github: 'spree/spree', branch: 'main'
|
8
|
+
gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
|
8
9
|
gem 'rspec_junit_formatter', '~> 0.4.1'
|
9
10
|
|
11
|
+
if ENV['DB'] == 'mysql'
|
12
|
+
gem 'mysql2'
|
13
|
+
else
|
14
|
+
gem 'pg', '~> 1.1'
|
15
|
+
end
|
16
|
+
|
10
17
|
gem 'pry', '~> 0.14.1'
|
11
18
|
gemspec
|
data/README.md
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
|
5
5
|
Provides authentication services for [Spree](https://spreecommerce.org), using the [Devise](https://github.com/plataformatec/devise) gem.
|
6
6
|
|
7
|
+
## Developed by
|
8
|
+
|
9
|
+
[](https://getvendo.com?utm_source=spree_auth_github)
|
10
|
+
|
11
|
+
> All-in-one platform for all your Marketplace and B2B eCommerce needs. [Start your 30-day free trial](https://e98esoirr8c.typeform.com/contactvendo?typeform-source=spree_auth_github)
|
7
12
|
|
8
13
|
## Installation
|
9
14
|
|
@@ -130,14 +135,3 @@ You need to do a quick one-time creation of a test application and then you can
|
|
130
135
|
Then run the rspec tests.
|
131
136
|
|
132
137
|
bundle exec rspec
|
133
|
-
|
134
|
-
About Spark Solutions
|
135
|
-
----------------------
|
136
|
-
[][spark]
|
137
|
-
|
138
|
-
Spree Auth Devise is maintained by [Spark Solutions Sp. z o.o.][spark].
|
139
|
-
|
140
|
-
We are passionate about open source software.
|
141
|
-
We are [available for hire][spark].
|
142
|
-
|
143
|
-
[spark]:http://sparksolutions.co?utm_source=github
|
@@ -6,7 +6,7 @@ Devise.setup do |config|
|
|
6
6
|
config.mailer_sender = 'please-change-me@config-initializers-devise.com'
|
7
7
|
|
8
8
|
# Configure the class responsible to send e-mails.
|
9
|
-
config.mailer = 'Spree::UserMailer'
|
9
|
+
config.mailer = 'Spree::UserMailer' if defined?(Spree::Emails)
|
10
10
|
|
11
11
|
# ==> ORM configuration
|
12
12
|
# Load and configure the ORM. Supports :active_record (default) and
|
data/config/routes.rb
CHANGED
@@ -1,52 +1,54 @@
|
|
1
1
|
Spree::Core::Engine.add_routes do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
scope '(:locale)', locale: /#{Spree.available_locales.join('|')}/, defaults: { locale: nil } do
|
3
|
+
devise_for :spree_user,
|
4
|
+
class_name: Spree.user_class.to_s,
|
5
|
+
controllers: { sessions: 'spree/user_sessions',
|
6
|
+
registrations: 'spree/user_registrations',
|
7
|
+
passwords: 'spree/user_passwords',
|
8
|
+
confirmations: 'spree/user_confirmations' },
|
9
|
+
skip: [:unlocks, :omniauth_callbacks],
|
10
|
+
path_names: { sign_out: 'logout' },
|
11
|
+
path_prefix: :user
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
devise_scope :spree_user do
|
14
|
+
get '/login' => 'user_sessions#new', :as => :login
|
15
|
+
post '/login' => 'user_sessions#create', :as => :create_new_session
|
16
|
+
get '/logout' => 'user_sessions#destroy', :as => :logout
|
17
|
+
get '/signup' => 'user_registrations#new', :as => :signup
|
18
|
+
post '/signup' => 'user_registrations#create', :as => :registration
|
19
|
+
get '/password/recover' => 'user_passwords#new', :as => :recover_password
|
20
|
+
post '/password/recover' => 'user_passwords#create', :as => :reset_password
|
21
|
+
get '/password/change' => 'user_passwords#edit', :as => :edit_password
|
22
|
+
put '/password/change' => 'user_passwords#update', :as => :update_password
|
23
|
+
get '/confirm' => 'user_confirmations#show', :as => :confirmation
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
if Spree::Core::Engine.frontend_available?
|
27
|
+
resources :users, only: [:edit, :update]
|
28
|
+
get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
|
29
|
+
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
|
30
|
+
resource :account, controller: 'users'
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
33
|
+
if Spree.respond_to?(:admin_path) && Spree::Core::Engine.backend_available?
|
34
|
+
namespace :admin, path: Spree.admin_path do
|
35
|
+
devise_for :spree_user,
|
36
|
+
class_name: Spree.user_class.to_s,
|
37
|
+
controllers: { sessions: 'spree/admin/user_sessions',
|
38
|
+
passwords: 'spree/admin/user_passwords' },
|
39
|
+
skip: [:unlocks, :omniauth_callbacks, :registrations],
|
40
|
+
path_names: { sign_out: 'logout' },
|
41
|
+
path_prefix: :user
|
42
|
+
devise_scope :spree_user do
|
43
|
+
get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
|
44
|
+
get '/login' => 'user_sessions#new', :as => :login
|
45
|
+
post '/login' => 'user_sessions#create', :as => :create_new_session
|
46
|
+
get '/logout' => 'user_sessions#destroy', :as => :logout
|
47
|
+
get '/password/recover' => 'user_passwords#new', :as => :recover_password
|
48
|
+
post '/password/recover' => 'user_passwords#create', :as => :reset_password
|
49
|
+
get '/password/change' => 'user_passwords#edit', :as => :edit_password
|
50
|
+
put '/password/change' => 'user_passwords#update', :as => :update_password
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -5,7 +5,7 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
|
5
5
|
include Spree::Core::ControllerHelpers::Store
|
6
6
|
|
7
7
|
helper 'spree/admin/navigation'
|
8
|
-
layout 'spree/layouts/
|
8
|
+
layout 'spree/layouts/login'
|
9
9
|
|
10
10
|
# Overridden due to bug in Devise.
|
11
11
|
# respond_with resource, :location => new_session_path(resource_name)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Spree::Admin::BaseControllerDecorator
|
1
|
+
module Spree::Auth::Admin::BaseControllerDecorator
|
2
2
|
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
|
3
3
|
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
|
4
4
|
# to access the requested action. For example, a popup window might simply close itself.
|
@@ -22,4 +22,4 @@ module Spree::Admin::BaseControllerDecorator
|
|
22
22
|
nil
|
23
23
|
end
|
24
24
|
end
|
25
|
-
Spree::Admin::BaseController.prepend(Spree::Admin::BaseControllerDecorator)
|
25
|
+
::Spree::Admin::BaseController.prepend(Spree::Auth::Admin::BaseControllerDecorator)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Spree::Admin::Orders::CustomerDetailsControllerDecorator
|
1
|
+
module Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator
|
2
2
|
|
3
3
|
def self.prepended(base)
|
4
4
|
base.before_action :check_authorization
|
@@ -17,4 +17,4 @@ module Spree::Admin::Orders::CustomerDetailsControllerDecorator
|
|
17
17
|
authorize! action, resource, session[:access_token]
|
18
18
|
end
|
19
19
|
end
|
20
|
-
Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Admin::Orders::CustomerDetailsControllerDecorator)
|
20
|
+
Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Spree::Admin::OrdersControllerDecorator
|
1
|
+
module Spree::Auth::Admin::OrdersControllerDecorator
|
2
2
|
|
3
3
|
def self.prepended(base)
|
4
4
|
base.before_action :check_authorization
|
@@ -22,4 +22,4 @@ module Spree::Admin::OrdersControllerDecorator
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
Spree::Admin::OrdersController.prepend(Spree::Admin::OrdersControllerDecorator)
|
25
|
+
Spree::Admin::OrdersController.prepend(Spree::Auth::Admin::OrdersControllerDecorator)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spree/core/validators/email' if Spree.version.to_f < 3.5
|
2
|
-
module Spree::CheckoutControllerDecorator
|
2
|
+
module Spree::Auth::CheckoutControllerDecorator
|
3
3
|
def self.prepended(base)
|
4
4
|
base.before_action :check_authorization
|
5
5
|
base.before_action :check_registration, except: [:registration, :update_registration]
|
6
6
|
end
|
7
7
|
|
8
8
|
def registration
|
9
|
-
@user = Spree.user_class.new
|
9
|
+
@user = Spree.user_class.new
|
10
10
|
@title = Spree.t(:registration)
|
11
11
|
end
|
12
12
|
|
@@ -16,7 +16,7 @@ module Spree::CheckoutControllerDecorator
|
|
16
16
|
else
|
17
17
|
flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
|
18
18
|
@user = Spree.user_class.new
|
19
|
-
render 'registration'
|
19
|
+
render 'registration', status: :unprocessable_entity
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -42,4 +42,4 @@ module Spree::CheckoutControllerDecorator
|
|
42
42
|
redirect_to spree.checkout_registration_path
|
43
43
|
end
|
44
44
|
end
|
45
|
-
Spree::CheckoutController.prepend(Spree::CheckoutControllerDecorator)
|
45
|
+
Spree::CheckoutController.prepend(Spree::Auth::CheckoutControllerDecorator)
|
@@ -33,7 +33,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
33
33
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
34
34
|
respond_with resource, location: spree.login_path
|
35
35
|
else
|
36
|
-
respond_with_navigational(resource) { render :new }
|
36
|
+
respond_with_navigational(resource) { render :new, status: :unprocessable_entity }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
45
45
|
self.resource = resource_class.new
|
46
46
|
resource.reset_password_token = params[:spree_user][:reset_password_token]
|
47
47
|
set_flash_message(:error, :cannot_be_blank)
|
48
|
-
render :edit
|
48
|
+
render :edit, status: :unprocessable_entity
|
49
49
|
else
|
50
50
|
super
|
51
51
|
end
|
@@ -48,7 +48,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
48
48
|
end
|
49
49
|
else
|
50
50
|
clean_up_passwords(resource)
|
51
|
-
render :new
|
51
|
+
render :new, status: :unprocessable_entity
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -94,7 +94,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
94
94
|
scope = Devise::Mapping.find_scope!(resource)
|
95
95
|
router_name = Devise.mappings[scope].router_name
|
96
96
|
context = router_name ? send(router_name) : self
|
97
|
-
context.respond_to?(:login_path) ? context.login_path :
|
97
|
+
context.respond_to?(:login_path) ? context.login_path(locale_param) : spree.root_path
|
98
98
|
end
|
99
99
|
|
100
100
|
private
|
@@ -104,7 +104,9 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def spree_user_params
|
107
|
-
params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
|
107
|
+
user_params = params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
|
108
|
+
user_params[:selected_locale] = current_locale
|
109
|
+
user_params
|
108
110
|
end
|
109
111
|
|
110
112
|
def after_sign_in_redirect(resource_or_scope)
|
@@ -38,7 +38,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
38
38
|
respond_to do |format|
|
39
39
|
format.html {
|
40
40
|
flash.now[:error] = t('devise.failure.invalid')
|
41
|
-
render :new
|
41
|
+
render :new, status: :unprocessable_entity
|
42
42
|
}
|
43
43
|
format.js {
|
44
44
|
render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
|
@@ -81,6 +81,6 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
81
81
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
82
82
|
router_name = Devise.mappings[scope].router_name
|
83
83
|
context = router_name ? send(router_name) : self
|
84
|
-
context.respond_to?(:login_path) ? context.login_path : spree.root_path
|
84
|
+
context.respond_to?(:login_path) ? context.login_path(locale_param) : spree.root_path
|
85
85
|
end
|
86
86
|
end
|
@@ -23,7 +23,7 @@ class Spree::UsersController < Spree::StoreController
|
|
23
23
|
|
24
24
|
redirect_back_or_default(root_url)
|
25
25
|
else
|
26
|
-
render :new
|
26
|
+
render :new, status: :unprocessable_entity
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -41,7 +41,7 @@ class Spree::UsersController < Spree::StoreController
|
|
41
41
|
end
|
42
42
|
redirect_to spree.account_path, notice: Spree.t(:account_updated)
|
43
43
|
else
|
44
|
-
render :edit
|
44
|
+
render :edit, status: :unprocessable_entity
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Spree
|
2
|
+
class UserMailer < BaseMailer
|
3
|
+
def reset_password_instructions(user, token, opts = {})
|
4
|
+
@user = user
|
5
|
+
@current_store = current_store(opts)
|
6
|
+
@edit_password_reset_url = edit_password_url(token, @current_store)
|
7
|
+
|
8
|
+
mail to: user.email, from: from_address, reply_to: reply_to_address,
|
9
|
+
subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]),
|
10
|
+
store_url: @current_store.url
|
11
|
+
end
|
12
|
+
|
13
|
+
def confirmation_instructions(user, token, opts = {})
|
14
|
+
@user = user
|
15
|
+
@current_store = current_store(opts)
|
16
|
+
@confirmation_url = spree.confirmation_url(confirmation_token: token, host: @current_store.url)
|
17
|
+
@email = user.email
|
18
|
+
|
19
|
+
mail to: user.email, from: from_address, reply_to: reply_to_address,
|
20
|
+
subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]),
|
21
|
+
store_url: @current_store.url
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def edit_password_url(token, store)
|
27
|
+
if frontend_available?
|
28
|
+
spree.edit_password_url(reset_password_token: token, host: store.url)
|
29
|
+
else
|
30
|
+
spree.admin_edit_password_url(reset_password_token: token, host: store.url)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def current_store(opts = {})
|
35
|
+
@current_store = Spree::Store.find_by(id: opts[:current_store_id]) || Spree::Store.default
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Spree
|
2
|
+
module Auth
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :registration_step,
|
5
|
+
:signout_after_password_change,
|
6
|
+
:confirmable,
|
7
|
+
:validatable
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
self.registration_step = true
|
11
|
+
self.signout_after_password_change = true
|
12
|
+
self.confirmable = false
|
13
|
+
self.validatable = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield(self) if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(preference)
|
21
|
+
send(preference)
|
22
|
+
end
|
23
|
+
|
24
|
+
alias [] get
|
25
|
+
|
26
|
+
def set(preference, value)
|
27
|
+
send("#{preference}=", value)
|
28
|
+
end
|
29
|
+
|
30
|
+
alias []= set
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/spree/auth/engine.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'devise'
|
2
2
|
require 'devise-encryptable'
|
3
3
|
|
4
|
+
require_relative 'configuration'
|
5
|
+
|
4
6
|
module Spree
|
5
7
|
module Auth
|
6
8
|
class Engine < Rails::Engine
|
@@ -8,11 +10,11 @@ module Spree
|
|
8
10
|
engine_name 'spree_auth'
|
9
11
|
|
10
12
|
initializer "spree.auth.environment", before: :load_config_initializers do |_app|
|
11
|
-
Spree::Auth::Config = Spree::
|
13
|
+
Spree::Auth::Config = Spree::Auth::Configuration.new
|
12
14
|
end
|
13
15
|
|
14
16
|
initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do
|
15
|
-
Spree.user_class = 'Spree::User'
|
17
|
+
Spree.user_class = 'Spree::User'
|
16
18
|
end
|
17
19
|
|
18
20
|
initializer "spree_auth_devise.check_secret_token" do
|
@@ -55,13 +57,17 @@ module Spree
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def self.frontend_available?
|
58
|
-
@@frontend_available ||= ::
|
60
|
+
@@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any?
|
59
61
|
end
|
60
62
|
|
61
63
|
def self.api_available?
|
62
64
|
@@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
|
63
65
|
end
|
64
66
|
|
67
|
+
def self.emails_available?
|
68
|
+
@@emails_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Emails::Engine')
|
69
|
+
end
|
70
|
+
|
65
71
|
if backend_available?
|
66
72
|
paths["app/controllers"] << "lib/controllers/backend"
|
67
73
|
paths["app/views"] << "lib/views/backend"
|
@@ -76,6 +82,11 @@ module Spree
|
|
76
82
|
paths["app/controllers"] << "lib/controllers/api"
|
77
83
|
end
|
78
84
|
|
85
|
+
if emails_available?
|
86
|
+
paths["app/views"] << "lib/views/emails"
|
87
|
+
paths["app/mailers"] << "lib/mailers"
|
88
|
+
end
|
89
|
+
|
79
90
|
config.to_prepare &method(:activate).to_proc
|
80
91
|
end
|
81
92
|
end
|
data/lib/spree/auth/version.rb
CHANGED
@@ -11,16 +11,16 @@ module Spree
|
|
11
11
|
current_spree_user
|
12
12
|
end
|
13
13
|
|
14
|
-
def spree_login_path
|
15
|
-
spree.login_path
|
14
|
+
def spree_login_path(opts = {})
|
15
|
+
spree.login_path(opts)
|
16
16
|
end
|
17
17
|
|
18
|
-
def spree_signup_path
|
19
|
-
spree.signup_path
|
18
|
+
def spree_signup_path(opts = {})
|
19
|
+
spree.signup_path(opts)
|
20
20
|
end
|
21
21
|
|
22
|
-
def spree_logout_path
|
23
|
-
spree.logout_path
|
22
|
+
def spree_logout_path(opts = {})
|
23
|
+
spree.logout_path(opts)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -39,6 +39,14 @@ module Spree
|
|
39
39
|
click_link Spree.t(:my_account).upcase
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
def wait_for_turbo
|
44
|
+
if Spree.version.to_f < 4.5
|
45
|
+
expect(page).to have_no_css '.turbolinks-progress-bar'
|
46
|
+
else
|
47
|
+
expect(page).to have_no_css '.turbo-progress-bar'
|
48
|
+
end
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|