spree_auth_devise 4.4.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +177 -29
- data/Gemfile +12 -4
- data/README.md +6 -13
- data/app/models/spree/user.rb +3 -0
- data/config/initializers/devise.rb +1 -1
- data/config/routes.rb +33 -29
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +6 -5
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +1 -2
- 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 +1 -1
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +1 -1
- data/lib/mailers/spree/user_mailer.rb +38 -0
- data/lib/spree/auth/configuration.rb +10 -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 +18 -15
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +13 -15
- 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 +12 -13
- data/lib/views/backend/spree/layouts/login.html.erb +1 -1
- 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
- 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/products_controller_spec.rb +1 -0
- data/spec/features/account_spec.rb +1 -0
- data/spec/features/admin/password_reset_spec.rb +1 -1
- data/spec/features/admin/sign_in_spec.rb +1 -1
- data/spec/features/admin/sign_out_spec.rb +2 -2
- data/spec/features/checkout_spec.rb +4 -3
- data/spec/features/confirmation_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +1 -1
- data/spec/mailers/user_mailer_spec.rb +3 -3
- data/spec/models/user_spec.rb +3 -3
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +0 -9
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a85c3ec56e4d12970bf8abf6f8365a688cea123c9be66d5e7d9581ca51468bbc
|
|
4
|
+
data.tar.gz: 6cd1ecf12edd93fc0ff505c9d21eadf139f218f1fd2be0870d64d68d833fa712
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b55e45f4cd927c1d3a0509f9c4d04ff60d03f1453cb2878911ddd4137834d338cf506db686572ab17e5bc99534dffbc822b36201c92bc6f6a58b1480d8a0041
|
|
7
|
+
data.tar.gz: 1edd8464cdef3be084845fb5eef65e33b9ac86c82e7fb19c35ab6acd29ad60e4a69114bf3a3917f14e150367b0df426c0a85b8340e5110e0443c3c41520f38d8
|
data/.circleci/config.yml
CHANGED
|
@@ -1,41 +1,189 @@
|
|
|
1
|
-
version: 2
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
defaults: &defaults
|
|
4
|
+
environment: &environment
|
|
5
|
+
CIRCLE_TEST_REPORTS: /tmp/test-results
|
|
6
|
+
CIRCLE_ARTIFACTS: /tmp/test-artifacts
|
|
7
|
+
BUNDLE_JOBS: 4
|
|
8
|
+
BUNDLE_RETRY: 3
|
|
9
|
+
BUNDLE_PATH: ~/spree/vendor/bundle
|
|
10
|
+
working_directory: ~/spree
|
|
11
|
+
docker:
|
|
12
|
+
- image: &ruby_image circleci/ruby:2.7-node-browsers
|
|
13
|
+
- image: &redis_image circleci/redis:6.2-alpine
|
|
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
|
+
run_tests: &run_tests
|
|
22
|
+
<<: *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: Install libvips
|
|
31
|
+
command: sudo apt-get install libvips
|
|
32
|
+
- run:
|
|
33
|
+
name: Set bundle path
|
|
34
|
+
command: bundle config --local path vendor/bundle
|
|
35
|
+
- run:
|
|
36
|
+
name: Ensure bundle Install
|
|
37
|
+
command: |
|
|
38
|
+
bundle check || bundle install
|
|
39
|
+
- run:
|
|
40
|
+
name: Create test app
|
|
41
|
+
command: |
|
|
42
|
+
bundle exec rake test_app
|
|
43
|
+
- run:
|
|
44
|
+
name: Run Rspec
|
|
45
|
+
command: |
|
|
46
|
+
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
47
|
+
bundle exec rspec --format documentation \
|
|
48
|
+
--format RspecJunitFormatter \
|
|
49
|
+
-o ~/rspec/rspec.xml \
|
|
50
|
+
-- ${TESTFILES}
|
|
51
|
+
- store_test_results:
|
|
52
|
+
path: ~/rspec
|
|
53
|
+
- store_artifacts:
|
|
54
|
+
path: tmp/capybara
|
|
55
|
+
|
|
56
|
+
run_tests_3_0: &run_tests_3_0
|
|
57
|
+
<<: *defaults_3_0
|
|
58
|
+
steps:
|
|
59
|
+
- checkout
|
|
60
|
+
- restore_cache:
|
|
61
|
+
keys:
|
|
62
|
+
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
|
63
|
+
- spree-auth-devise-bundle-v9-ruby-3-0
|
|
64
|
+
- run:
|
|
65
|
+
name: Install libvips
|
|
66
|
+
command: sudo apt-get install libvips
|
|
67
|
+
- run:
|
|
68
|
+
name: Set bundle path
|
|
69
|
+
command: bundle config --local path vendor/bundle
|
|
70
|
+
- run:
|
|
71
|
+
name: Ensure bundle Install
|
|
72
|
+
command: |
|
|
73
|
+
bundle check || bundle install
|
|
74
|
+
- run:
|
|
75
|
+
name: Create test app
|
|
76
|
+
command: |
|
|
77
|
+
bundle exec rake test_app
|
|
78
|
+
- run:
|
|
79
|
+
name: Run Rspec
|
|
80
|
+
command: |
|
|
81
|
+
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
82
|
+
bundle exec rspec --format documentation \
|
|
83
|
+
--format RspecJunitFormatter \
|
|
84
|
+
-o ~/rspec/rspec.xml \
|
|
85
|
+
-- ${TESTFILES}
|
|
86
|
+
- store_test_results:
|
|
87
|
+
path: ~/rspec
|
|
88
|
+
- store_artifacts:
|
|
89
|
+
path: tmp/capybara
|
|
2
90
|
|
|
3
91
|
jobs:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- image: circleci/ruby:2.6.3
|
|
92
|
+
bundle:
|
|
93
|
+
<<: *defaults
|
|
7
94
|
steps:
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- run: ssh-add -D
|
|
14
|
-
- run: ssh-add ~/.ssh/id_rsa_54505e4e806d2e2643c699bd39b271dc
|
|
15
|
-
- run: git clone -b master git@github.com:spark-solutions/spree-designs.git
|
|
16
|
-
- run: gem install bundler -v 1.17.3
|
|
95
|
+
- checkout
|
|
96
|
+
- restore_cache:
|
|
97
|
+
keys:
|
|
98
|
+
- spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
|
|
99
|
+
- spree-auth-devise-bundle-v9-ruby-2-7
|
|
17
100
|
- run:
|
|
18
|
-
|
|
19
|
-
|
|
101
|
+
name: Install libvips
|
|
102
|
+
command: sudo apt-get install libvips
|
|
20
103
|
- run:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
git config user.email 'autodeploy@sparksolutions.co'
|
|
24
|
-
working_directory: ~/project/spree-designs
|
|
104
|
+
name: Set bundle path
|
|
105
|
+
command: bundle config --local path vendor/bundle
|
|
25
106
|
- run:
|
|
107
|
+
name: Bundle Install
|
|
26
108
|
command: |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
109
|
+
bundle check || bundle install
|
|
110
|
+
- save_cache:
|
|
111
|
+
paths:
|
|
112
|
+
- vendor/bundle
|
|
113
|
+
key: spree-auth-devise-bundle-v9-ruby-2-7-{{ checksum "Gemfile.lock" }}
|
|
114
|
+
|
|
115
|
+
bundle_ruby_3_0:
|
|
116
|
+
<<: *defaults_3_0
|
|
117
|
+
steps:
|
|
118
|
+
- checkout
|
|
119
|
+
- restore_cache:
|
|
120
|
+
keys:
|
|
121
|
+
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
|
122
|
+
- spree-auth-devise-bundle-v9-ruby-3-0
|
|
123
|
+
- run:
|
|
124
|
+
name: Install libvips
|
|
125
|
+
command: sudo apt-get install libvips
|
|
30
126
|
- run:
|
|
31
|
-
|
|
32
|
-
|
|
127
|
+
name: Set bundle path
|
|
128
|
+
command: bundle config --local path vendor/bundle
|
|
129
|
+
- run:
|
|
130
|
+
name: Bundle Install
|
|
131
|
+
command: |
|
|
132
|
+
bundle check || bundle install
|
|
133
|
+
- save_cache:
|
|
134
|
+
paths:
|
|
135
|
+
- vendor/bundle
|
|
136
|
+
key: spree-auth-devise-bundle-v9-ruby-3-0-{{ checksum "Gemfile.lock" }}
|
|
137
|
+
|
|
138
|
+
tests_postgres: &tests_postgres
|
|
139
|
+
<<: *run_tests
|
|
140
|
+
environment: &postgres_environment
|
|
141
|
+
<<: *environment
|
|
142
|
+
DB: postgres
|
|
143
|
+
DB_HOST: localhost
|
|
144
|
+
DB_USERNAME: postgres
|
|
145
|
+
docker:
|
|
146
|
+
- image: *ruby_image
|
|
147
|
+
- image: *redis_image
|
|
148
|
+
- image: &postgres_image circleci/postgres:12-alpine
|
|
149
|
+
environment:
|
|
150
|
+
POSTGRES_USER: postgres
|
|
151
|
+
|
|
152
|
+
tests_postgres_ruby_3_0: &tests_postgres_ruby_3_0
|
|
153
|
+
<<: *run_tests_3_0
|
|
154
|
+
environment:
|
|
155
|
+
<<: *postgres_environment
|
|
156
|
+
docker:
|
|
157
|
+
- image: *ruby_3_0_image
|
|
158
|
+
- image: *postgres_image
|
|
159
|
+
- image: *redis_image
|
|
160
|
+
|
|
161
|
+
tests_mysql: &tests_mysql
|
|
162
|
+
<<: *run_tests
|
|
163
|
+
environment: &mysql_environment
|
|
164
|
+
<<: *environment
|
|
165
|
+
DB: mysql
|
|
166
|
+
DB_HOST: 127.0.0.1
|
|
167
|
+
DB_USERNAME: root
|
|
168
|
+
COVERAGE: true
|
|
169
|
+
COVERAGE_DIR: /tmp/workspace/simplecov
|
|
170
|
+
docker:
|
|
171
|
+
- image: *ruby_image
|
|
172
|
+
- image: *redis_image
|
|
173
|
+
- image: &mysql_image circleci/mysql:8-ram
|
|
33
174
|
|
|
34
175
|
workflows:
|
|
35
176
|
version: 2
|
|
36
|
-
|
|
177
|
+
main:
|
|
37
178
|
jobs:
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
179
|
+
- bundle
|
|
180
|
+
- bundle_ruby_3_0
|
|
181
|
+
- tests_postgres:
|
|
182
|
+
requires:
|
|
183
|
+
- bundle
|
|
184
|
+
- tests_postgres_ruby_3_0:
|
|
185
|
+
requires:
|
|
186
|
+
- bundle_ruby_3_0
|
|
187
|
+
- tests_mysql:
|
|
188
|
+
requires:
|
|
189
|
+
- bundle
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gem 'rails-controller-testing'
|
|
4
|
-
gem '
|
|
5
|
-
gem '
|
|
6
|
-
gem '
|
|
7
|
-
gem 'spree_emails', '
|
|
4
|
+
gem 'devise', github: 'heartcombo/devise', branch: 'main'
|
|
5
|
+
gem 'spree', github: 'spree/spree', branch: 'main'
|
|
6
|
+
gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
|
|
7
|
+
gem 'spree_emails', github: 'spree/spree', branch: 'main'
|
|
8
|
+
gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
|
|
9
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
|
10
|
+
|
|
11
|
+
if ENV['DB'] == 'mysql'
|
|
12
|
+
gem 'mysql2'
|
|
13
|
+
else
|
|
14
|
+
gem 'pg', '~> 1.1'
|
|
15
|
+
end
|
|
8
16
|
|
|
9
17
|
gem 'pry', '~> 0.14.1'
|
|
10
18
|
gemspec
|
data/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# Spree Auth (Devise)
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/spree/spree_auth_devise)
|
|
3
|
+
[](https://circleci.com/gh/spree/spree_auth_devise/tree/main)
|
|
5
4
|
|
|
6
5
|
Provides authentication services for [Spree](https://spreecommerce.org), using the [Devise](https://github.com/plataformatec/devise) gem.
|
|
7
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)
|
|
8
12
|
|
|
9
13
|
## Installation
|
|
10
14
|
|
|
@@ -131,14 +135,3 @@ You need to do a quick one-time creation of a test application and then you can
|
|
|
131
135
|
Then run the rspec tests.
|
|
132
136
|
|
|
133
137
|
bundle exec rspec
|
|
134
|
-
|
|
135
|
-
About Spark Solutions
|
|
136
|
-
----------------------
|
|
137
|
-
[][spark]
|
|
138
|
-
|
|
139
|
-
Spree Auth Devise is maintained by [Spark Solutions Sp. z o.o.][spark].
|
|
140
|
-
|
|
141
|
-
We are passionate about open source software.
|
|
142
|
-
We are [available for hire][spark].
|
|
143
|
-
|
|
144
|
-
[spark]:http://sparksolutions.co?utm_source=github
|
data/app/models/spree/user.rb
CHANGED
|
@@ -3,6 +3,9 @@ module Spree
|
|
|
3
3
|
include UserAddress
|
|
4
4
|
include UserMethods
|
|
5
5
|
include UserPaymentSource
|
|
6
|
+
if defined?(Spree::Metadata)
|
|
7
|
+
include Metadata
|
|
8
|
+
end
|
|
6
9
|
|
|
7
10
|
devise :database_authenticatable, :registerable, :recoverable,
|
|
8
11
|
:rememberable, :trackable, :encryptable, encryptor: 'authlogic_sha512'
|
|
@@ -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,15 +1,13 @@
|
|
|
1
1
|
Spree::Core::Engine.add_routes do
|
|
2
2
|
devise_for :spree_user,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
resources :users, only: [:edit, :update]
|
|
3
|
+
class_name: Spree.user_class.to_s,
|
|
4
|
+
controllers: { sessions: 'spree/user_sessions',
|
|
5
|
+
registrations: 'spree/user_registrations',
|
|
6
|
+
passwords: 'spree/user_passwords',
|
|
7
|
+
confirmations: 'spree/user_confirmations' },
|
|
8
|
+
skip: [:unlocks, :omniauth_callbacks],
|
|
9
|
+
path_names: { sign_out: 'logout' },
|
|
10
|
+
path_prefix: :user
|
|
13
11
|
|
|
14
12
|
devise_scope :spree_user do
|
|
15
13
|
get '/login' => 'user_sessions#new', :as => :login
|
|
@@ -24,26 +22,32 @@ Spree::Core::Engine.add_routes do
|
|
|
24
22
|
get '/confirm' => 'user_confirmations#show', :as => :confirmation
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if Spree::Core::Engine.frontend_available?
|
|
26
|
+
resources :users, only: [:edit, :update]
|
|
27
|
+
get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
|
|
28
|
+
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
|
|
29
|
+
resource :account, controller: 'users'
|
|
30
|
+
end
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
if Spree.respond_to?(:admin_path) && Spree::Core::Engine.backend_available?
|
|
33
|
+
namespace :admin, path: Spree.admin_path do
|
|
34
|
+
devise_for :spree_user,
|
|
35
|
+
class_name: Spree.user_class.to_s,
|
|
36
|
+
controllers: { sessions: 'spree/admin/user_sessions',
|
|
37
|
+
passwords: 'spree/admin/user_passwords' },
|
|
38
|
+
skip: [:unlocks, :omniauth_callbacks, :registrations],
|
|
39
|
+
path_names: { sign_out: 'logout' },
|
|
40
|
+
path_prefix: :user
|
|
41
|
+
devise_scope :spree_user do
|
|
42
|
+
get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
|
|
43
|
+
get '/login' => 'user_sessions#new', :as => :login
|
|
44
|
+
post '/login' => 'user_sessions#create', :as => :create_new_session
|
|
45
|
+
get '/logout' => 'user_sessions#destroy', :as => :logout
|
|
46
|
+
get '/password/recover' => 'user_passwords#new', :as => :recover_password
|
|
47
|
+
post '/password/recover' => 'user_passwords#create', :as => :reset_password
|
|
48
|
+
get '/password/change' => 'user_passwords#edit', :as => :edit_password
|
|
49
|
+
put '/password/change' => 'user_passwords#update', :as => :update_password
|
|
50
|
+
end
|
|
47
51
|
end
|
|
48
52
|
end
|
|
49
53
|
|
|
@@ -2,11 +2,10 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
|
|
2
2
|
helper 'spree/base'
|
|
3
3
|
|
|
4
4
|
include Spree::Core::ControllerHelpers::Auth
|
|
5
|
-
include Spree::Core::ControllerHelpers::Common
|
|
6
5
|
include Spree::Core::ControllerHelpers::Store
|
|
7
6
|
|
|
8
7
|
helper 'spree/admin/navigation'
|
|
9
|
-
layout 'spree/layouts/
|
|
8
|
+
layout 'spree/layouts/login'
|
|
10
9
|
|
|
11
10
|
# Overridden due to bug in Devise.
|
|
12
11
|
# respond_with resource, :location => new_session_path(resource_name)
|
|
@@ -16,13 +15,13 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
|
|
16
15
|
# respond_with resource, :location => spree.login_path
|
|
17
16
|
#
|
|
18
17
|
def create
|
|
19
|
-
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
|
18
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name], current_store)
|
|
20
19
|
|
|
21
20
|
if resource.errors.empty?
|
|
22
21
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
|
23
22
|
respond_with resource, location: spree.admin_login_path
|
|
24
23
|
else
|
|
25
|
-
respond_with_navigational(resource) { render :new }
|
|
24
|
+
respond_with_navigational(resource) { render :new, status: :unprocessable_entity }
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
@@ -31,8 +30,10 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
|
|
31
30
|
# Fixes spree/spree#2190.
|
|
32
31
|
def update
|
|
33
32
|
if params[:spree_user][:password].blank?
|
|
33
|
+
self.resource = resource_class.new
|
|
34
|
+
resource.reset_password_token = params[:spree_user][:reset_password_token]
|
|
34
35
|
set_flash_message(:error, :cannot_be_blank)
|
|
35
|
-
render :edit
|
|
36
|
+
render :edit, status: :unprocessable_entity
|
|
36
37
|
else
|
|
37
38
|
super
|
|
38
39
|
end
|
|
@@ -2,7 +2,6 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
|
|
|
2
2
|
helper 'spree/base'
|
|
3
3
|
|
|
4
4
|
include Spree::Core::ControllerHelpers::Auth
|
|
5
|
-
include Spree::Core::ControllerHelpers::Common
|
|
6
5
|
include Spree::Core::ControllerHelpers::Store
|
|
7
6
|
|
|
8
7
|
helper 'spree/admin/navigation'
|
|
@@ -24,7 +23,7 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
|
|
|
24
23
|
end
|
|
25
24
|
else
|
|
26
25
|
flash.now[:error] = t('devise.failure.invalid')
|
|
27
|
-
render :new
|
|
26
|
+
render :new, status: :unprocessable_entity
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|
|
@@ -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
|
|
@@ -38,7 +38,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
|
38
38
|
respond_to do |format|
|
|
39
39
|
format.html {
|
|
40
40
|
flash.now[:error] = t('devise.failure.invalid')
|
|
41
|
-
render :new
|
|
41
|
+
render :new, status: :unprocessable_entity
|
|
42
42
|
}
|
|
43
43
|
format.js {
|
|
44
44
|
render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
class UserMailer < BaseMailer
|
|
3
|
+
def reset_password_instructions(user, token, opts = {})
|
|
4
|
+
@user = user
|
|
5
|
+
@current_store = current_store(opts)
|
|
6
|
+
@edit_password_reset_url = edit_password_url(token, @current_store)
|
|
7
|
+
|
|
8
|
+
mail to: user.email, from: from_address, reply_to: reply_to_address,
|
|
9
|
+
subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]),
|
|
10
|
+
store_url: @current_store.url
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def confirmation_instructions(user, token, opts = {})
|
|
14
|
+
@user = user
|
|
15
|
+
@current_store = current_store(opts)
|
|
16
|
+
@confirmation_url = spree.confirmation_url(confirmation_token: token, host: @current_store.url)
|
|
17
|
+
@email = user.email
|
|
18
|
+
|
|
19
|
+
mail to: user.email, from: from_address, reply_to: reply_to_address,
|
|
20
|
+
subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]),
|
|
21
|
+
store_url: @current_store.url
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def edit_password_url(token, store)
|
|
27
|
+
if frontend_available?
|
|
28
|
+
spree.edit_password_url(reset_password_token: token, host: store.url)
|
|
29
|
+
else
|
|
30
|
+
spree.admin_edit_password_url(reset_password_token: token, host: store.url)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def current_store(opts = {})
|
|
35
|
+
@current_store = Spree::Store.find_by(id: opts[:current_store_id]) || Spree::Store.default
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Auth
|
|
3
|
+
class Configuration < Preferences::Configuration
|
|
4
|
+
preference :registration_step, :boolean, default: true
|
|
5
|
+
preference :signout_after_password_change, :boolean, default: true
|
|
6
|
+
preference :confirmable, :boolean, default: false
|
|
7
|
+
preference :validatable, :boolean, default: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|