spree_auth_devise 4.0.0 → 4.2.1
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 +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +30 -37
- data/Appraisals +3 -14
- data/Gemfile +2 -2
- data/README.md +3 -12
- data/Rakefile +9 -3
- data/app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb +20 -0
- data/app/controllers/spree/api/v2/storefront/passwords_controller.rb +35 -0
- data/app/controllers/spree/user_confirmations_controller.rb +33 -0
- data/app/controllers/spree/user_passwords_controller.rb +13 -4
- data/app/controllers/spree/user_registrations_controller.rb +37 -4
- data/app/controllers/spree/user_sessions_controller.rb +33 -4
- data/app/mailers/spree/user_mailer.rb +6 -2
- data/app/models/spree/user.rb +17 -0
- data/app/services/spree/account/create.rb +19 -0
- data/app/services/spree/account/update.rb +17 -0
- data/app/views/spree/user_mailer/confirmation_instructions.text.erb +3 -3
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +2 -7
- data/app/views/spree/user_passwords/edit.html.erb +20 -17
- data/app/views/spree/user_passwords/new.html.erb +17 -15
- data/app/views/spree/user_registrations/new.html.erb +12 -17
- data/app/views/spree/user_sessions/new.html.erb +11 -12
- data/config/locales/de.yml +18 -0
- data/config/locales/en.yml +10 -3
- data/config/locales/zh-TW.yml +60 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +1 -1
- data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +41 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +10 -5
- data/lib/generators/spree/auth/install/install_generator.rb +0 -4
- data/lib/spree/auth/engine.rb +14 -1
- data/lib/spree/testing_support/auth_helpers.rb +36 -0
- data/lib/spree/testing_support/checkout_helpers.rb +24 -0
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
- data/spec/controllers/spree/admin/orders_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +63 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +12 -13
- data/spec/controllers/spree/products_controller_spec.rb +1 -1
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
- data/spec/controllers/spree/user_registrations_controller_spec.rb +8 -8
- data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
- data/spec/controllers/spree/users_controller_spec.rb +4 -4
- data/spec/features/account_spec.rb +10 -8
- data/spec/features/admin/password_reset_spec.rb +2 -4
- data/spec/features/admin/sign_in_spec.rb +13 -9
- data/spec/features/admin/sign_out_spec.rb +1 -1
- data/spec/features/admin_permissions_spec.rb +1 -1
- data/spec/features/change_email_spec.rb +1 -7
- data/spec/features/checkout_spec.rb +38 -63
- data/spec/features/confirmation_spec.rb +3 -5
- data/spec/features/order_spec.rb +9 -15
- data/spec/features/password_reset_spec.rb +2 -4
- data/spec/features/sign_in_spec.rb +21 -17
- data/spec/features/sign_out_spec.rb +14 -23
- data/spec/features/sign_up_spec.rb +6 -4
- data/spec/mailers/user_mailer_spec.rb +3 -3
- data/spec/models/user_spec.rb +9 -7
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +48 -0
- data/spec/requests/spree/api/v2/storefront/account_spec.rb +101 -0
- data/spec/requests/spree/frontend/user_update_spec.rb +42 -0
- data/spec/spec_helper.rb +7 -22
- data/spree_auth_devise.gemspec +6 -24
- metadata +42 -334
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/views/spree/shared/_login.html.erb +0 -18
- data/app/views/spree/shared/_user_form.html.erb +0 -17
- data/gemfiles/spree_3_2.gemfile +0 -8
- data/gemfiles/spree_3_7.gemfile +0 -9
- data/gemfiles/spree_4_0.gemfile +0 -8
- data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
- data/lib/assets/javascripts/spree/frontend/account.js +0 -8
- data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
- data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
- data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
- data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
- data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
- data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
- data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
- data/lib/views/frontend/spree/users/edit.html.erb +0 -17
- data/lib/views/frontend/spree/users/show.html.erb +0 -48
- data/spec/support/add_to_cart.rb +0 -15
- data/spec/support/authentication_helpers.rb +0 -14
- data/spec/support/cache_helpers.rb +0 -5
- data/spec/support/capybara.rb +0 -16
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/spree.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7cd5aef076f37e51acf8e77f9dc7aa8c14b3c38d38bb58c689fca12e59d6fc82
|
|
4
|
+
data.tar.gz: df4827dc1c68ed09ad300257ae97c9a10ad88e564a629bff09cd9b8568df9c6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a07f459d80a0260fd2a19a875d0ea6f392768c7d4a33db41574a238231e5a68234dc1e73c35d2287fb4eb73d9f30f9ac0ea1cbfb86af35fe5418fb061daf116
|
|
7
|
+
data.tar.gz: b14f4d2f862e49522de9f4704baa56bb81f876185ee693e27171a5ba68eb1abe5cc2c527a2fe8e4c1dfc01620765093d4edd8d62ca98471633f9163af2fd4eda
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
jobs:
|
|
4
|
+
update_staging_repository:
|
|
5
|
+
docker:
|
|
6
|
+
- image: circleci/ruby:2.6.3
|
|
7
|
+
steps:
|
|
8
|
+
- add_ssh_keys:
|
|
9
|
+
fingerprints:
|
|
10
|
+
- 54:50:5e:4e:80:6d:2e:26:43:c6:99:bd:39:b2:71:dc
|
|
11
|
+
- run: mkdir -p ~/.ssh
|
|
12
|
+
- run: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
|
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
|
|
17
|
+
- run:
|
|
18
|
+
command: bundle update spree_auth_devise
|
|
19
|
+
working_directory: ~/project/spree-designs
|
|
20
|
+
- run:
|
|
21
|
+
command: |
|
|
22
|
+
git config user.name 'AutoDeploy'
|
|
23
|
+
git config user.email 'autodeploy@sparksolutions.co'
|
|
24
|
+
working_directory: ~/project/spree-designs
|
|
25
|
+
- run:
|
|
26
|
+
command: |
|
|
27
|
+
git add -A
|
|
28
|
+
git commit -m "Auto-commit v#${CIRCLE_BUILD_NUM}"
|
|
29
|
+
working_directory: ~/project/spree-designs
|
|
30
|
+
- run:
|
|
31
|
+
command: git push origin master
|
|
32
|
+
working_directory: ~/project/spree-designs
|
|
33
|
+
|
|
34
|
+
workflows:
|
|
35
|
+
version: 2
|
|
36
|
+
update_staging_repository:
|
|
37
|
+
jobs:
|
|
38
|
+
- update_staging_repository:
|
|
39
|
+
filters:
|
|
40
|
+
branches:
|
|
41
|
+
only: master
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
dist:
|
|
3
|
-
|
|
4
|
-
script:
|
|
5
|
-
- bundle exec rake test_app
|
|
6
|
-
- bundle exec rake spec
|
|
1
|
+
os: linux
|
|
2
|
+
dist: bionic
|
|
7
3
|
|
|
8
4
|
addons:
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
apt:
|
|
6
|
+
sources:
|
|
7
|
+
- google-chrome
|
|
8
|
+
packages:
|
|
9
|
+
- google-chrome-stable
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
11
|
+
services:
|
|
12
|
+
- mysql
|
|
13
|
+
- postgresql
|
|
15
14
|
|
|
16
15
|
language: ruby
|
|
17
16
|
|
|
18
17
|
rvm:
|
|
19
|
-
- 2.5
|
|
20
|
-
- 2.
|
|
21
|
-
|
|
18
|
+
- 2.5
|
|
19
|
+
- 2.6
|
|
20
|
+
|
|
21
|
+
env:
|
|
22
|
+
- DB=mysql
|
|
23
|
+
- DB=postgres
|
|
22
24
|
|
|
23
25
|
gemfile:
|
|
24
|
-
- gemfiles/
|
|
25
|
-
- gemfiles/spree_3_7.gemfile
|
|
26
|
-
- gemfiles/spree_4_0.gemfile
|
|
26
|
+
- gemfiles/spree_4_1.gemfile
|
|
27
27
|
- gemfiles/spree_master.gemfile
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exclude:
|
|
33
|
-
- rvm: 2.3.8
|
|
34
|
-
gemfile: gemfiles/spree_4_0.gemfile
|
|
35
|
-
- rvm: 2.4.4
|
|
36
|
-
gemfile: gemfiles/spree_4_0.gemfile
|
|
37
|
-
- rvm: 2.3.8
|
|
38
|
-
gemfile: gemfiles/spree_master.gemfile
|
|
39
|
-
- rvm: 2.4.4
|
|
40
|
-
gemfile: gemfiles/spree_master.gemfile
|
|
41
|
-
- rvm: 2.5.1
|
|
42
|
-
gemfile: gemfiles/spree_3_5.gemfile
|
|
29
|
+
jobs:
|
|
30
|
+
allow_failures:
|
|
31
|
+
- gemfile: gemfiles/spree_master.gemfile
|
|
43
32
|
|
|
44
33
|
before_install:
|
|
45
34
|
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
35
|
+
|
|
36
|
+
before_script:
|
|
37
|
+
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
|
|
38
|
+
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
|
|
39
|
+
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
|
|
40
|
+
- unzip chromedriver_linux64.zip -d ~/bin
|
|
41
|
+
|
|
42
|
+
script:
|
|
43
|
+
- bundle exec rake test_app
|
|
44
|
+
- bundle exec rake spec
|
data/Appraisals
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
appraise 'spree-
|
|
2
|
-
gem 'spree', '~> 3.5.0'
|
|
3
|
-
gem 'rails-controller-testing'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
appraise 'spree-3-7' do
|
|
7
|
-
gem 'sass-rails'
|
|
8
|
-
gem 'spree', '~> 3.7.0'
|
|
9
|
-
gem 'rails-controller-testing'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
appraise 'spree-4-0' do
|
|
13
|
-
gem 'spree', '~> 4.0.0.rc2'
|
|
1
|
+
appraise 'spree-4-1' do
|
|
14
2
|
gem 'rails-controller-testing'
|
|
3
|
+
gem 'spree', '~> 4.1'
|
|
15
4
|
end
|
|
16
5
|
|
|
17
6
|
appraise 'spree-master' do
|
|
18
|
-
gem 'spree', github: 'spree/spree', branch: 'master'
|
|
19
7
|
gem 'rails-controller-testing'
|
|
8
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
|
20
9
|
end
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -10,20 +10,11 @@ Provides authentication services for [Spree](https://spreecommerce.org), using t
|
|
|
10
10
|
|
|
11
11
|
1. Add this extension to your Gemfile with this line:
|
|
12
12
|
|
|
13
|
-
#### Spree >= 3.1
|
|
14
|
-
|
|
15
|
-
```ruby
|
|
16
|
-
gem 'spree_auth_devise', '~> 3.3'
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
#### Spree 3.0 and Spree 2.x
|
|
20
|
-
|
|
21
13
|
```ruby
|
|
22
|
-
gem 'spree_auth_devise'
|
|
14
|
+
gem 'spree_auth_devise'
|
|
23
15
|
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
For example, use `3-0-stable` if you're using Spree `3-0-stable` or any `3.0.x` version.
|
|
16
|
+
|
|
17
|
+
if you run into any version-mismatch problems please run `bundle update`
|
|
27
18
|
|
|
28
19
|
2. Install the gem using Bundler:
|
|
29
20
|
```ruby
|
data/Rakefile
CHANGED
|
@@ -2,14 +2,20 @@ require 'bundler'
|
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
|
3
3
|
|
|
4
4
|
require 'rspec/core/rake_task'
|
|
5
|
-
require 'spree/testing_support/
|
|
5
|
+
require 'spree/testing_support/extension_rake'
|
|
6
6
|
|
|
7
7
|
RSpec::Core::RakeTask.new
|
|
8
8
|
|
|
9
|
-
task default
|
|
9
|
+
task :default do
|
|
10
|
+
if Dir["spec/dummy"].empty?
|
|
11
|
+
Rake::Task[:test_app].invoke
|
|
12
|
+
Dir.chdir("../../")
|
|
13
|
+
end
|
|
14
|
+
Rake::Task[:spec].invoke
|
|
15
|
+
end
|
|
10
16
|
|
|
11
17
|
desc 'Generates a dummy app for testing'
|
|
12
18
|
task :test_app do
|
|
13
19
|
ENV['LIB_NAME'] = 'spree/auth'
|
|
14
|
-
Rake::Task['
|
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
|
15
21
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Storefront
|
|
5
|
+
class AccountConfirmationsController < ::Spree::Api::V2::BaseController
|
|
6
|
+
|
|
7
|
+
def show
|
|
8
|
+
user = Spree.user_class.confirm_by_token(params[:id])
|
|
9
|
+
|
|
10
|
+
if user.errors.empty?
|
|
11
|
+
render json: { data: { state: user.respond_to?(:state) ? user.state : '' } }, status: :ok
|
|
12
|
+
else
|
|
13
|
+
render json: { error: user.errors.full_messages.to_sentence }, status: :unprocessable_entity
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Storefront
|
|
5
|
+
class PasswordsController < ::Spree::Api::V2::BaseController
|
|
6
|
+
include Spree::Core::ControllerHelpers::Store
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
user = Spree.user_class.find_by(email: params[:user][:email])
|
|
10
|
+
|
|
11
|
+
if user&.send_reset_password_instructions(current_store)
|
|
12
|
+
head :ok
|
|
13
|
+
else
|
|
14
|
+
head :not_found
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def update
|
|
19
|
+
user = Spree.user_class.reset_password_by_token(
|
|
20
|
+
password: params[:user][:password],
|
|
21
|
+
password_confirmation: params[:user][:password_confirmation],
|
|
22
|
+
reset_password_token: params[:id]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if user.errors.empty?
|
|
26
|
+
head :ok
|
|
27
|
+
else
|
|
28
|
+
render json: { error: user.errors.full_messages.to_sentence }, status: :unprocessable_entity
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -6,6 +6,39 @@ 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
|
+
|
|
20
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
|
21
|
+
def show
|
|
22
|
+
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
|
23
|
+
yield resource if block_given?
|
|
24
|
+
|
|
25
|
+
if resource.errors.empty?
|
|
26
|
+
set_flash_message!(:notice, :confirmed)
|
|
27
|
+
respond_with_navigational(resource) do
|
|
28
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
|
29
|
+
end
|
|
30
|
+
elsif resource.confirmed?
|
|
31
|
+
set_flash_message(:error, :already_confirmed)
|
|
32
|
+
respond_with_navigational(resource) do
|
|
33
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
|
34
|
+
end
|
|
35
|
+
else
|
|
36
|
+
respond_with_navigational(resource.errors, status: :unprocessable_entity) do
|
|
37
|
+
render :new
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
9
42
|
protected
|
|
10
43
|
|
|
11
44
|
def after_confirmation_path_for(resource_name, resource)
|
|
@@ -6,9 +6,18 @@ 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)
|
|
19
|
+
|
|
20
|
+
before_action :set_current_order
|
|
12
21
|
|
|
13
22
|
# Overridden due to bug in Devise.
|
|
14
23
|
# respond_with resource, :location => new_session_path(resource_name)
|
|
@@ -18,7 +27,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
|
18
27
|
# respond_with resource, :location => spree.login_path
|
|
19
28
|
#
|
|
20
29
|
def create
|
|
21
|
-
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
|
30
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name], current_store)
|
|
22
31
|
|
|
23
32
|
if resource.errors.empty?
|
|
24
33
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
|
@@ -6,11 +6,19 @@ 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]
|
|
21
|
+
before_action :set_current_order
|
|
14
22
|
skip_before_action :require_no_authentication
|
|
15
23
|
|
|
16
24
|
# GET /resource/sign_up
|
|
@@ -29,7 +37,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
|
29
37
|
set_flash_message :notice, :signed_up
|
|
30
38
|
sign_up(resource_name, resource)
|
|
31
39
|
session[:spree_user_signup] = true
|
|
32
|
-
|
|
40
|
+
redirect_to_checkout_or_account_path(resource)
|
|
33
41
|
else
|
|
34
42
|
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}"
|
|
35
43
|
expire_data_after_sign_in!
|
|
@@ -75,9 +83,34 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
|
75
83
|
'devise.user_registrations'
|
|
76
84
|
end
|
|
77
85
|
|
|
86
|
+
def after_sign_up_path_for(resource)
|
|
87
|
+
after_sign_in_redirect(resource) if is_navigational_format?
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def after_inactive_sign_up_path_for(resource)
|
|
91
|
+
scope = Devise::Mapping.find_scope!(resource)
|
|
92
|
+
router_name = Devise.mappings[scope].router_name
|
|
93
|
+
context = router_name ? send(router_name) : self
|
|
94
|
+
context.respond_to?(:login_path) ? context.login_path : "/login"
|
|
95
|
+
end
|
|
96
|
+
|
|
78
97
|
private
|
|
79
98
|
|
|
80
99
|
def spree_user_params
|
|
81
100
|
params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
|
|
82
101
|
end
|
|
102
|
+
|
|
103
|
+
def after_sign_in_redirect(resource_or_scope)
|
|
104
|
+
stored_location_for(resource_or_scope) || account_path
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def redirect_to_checkout_or_account_path(resource)
|
|
108
|
+
resource_path = after_sign_up_path_for(resource)
|
|
109
|
+
|
|
110
|
+
if resource_path == spree.checkout_state_path(:address)
|
|
111
|
+
respond_with resource, location: spree.checkout_state_path(:address)
|
|
112
|
+
else
|
|
113
|
+
respond_with resource, location: spree.account_path
|
|
114
|
+
end
|
|
115
|
+
end
|
|
83
116
|
end
|
|
@@ -6,9 +6,18 @@ 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)
|
|
19
|
+
|
|
20
|
+
before_action :set_current_order
|
|
12
21
|
|
|
13
22
|
def create
|
|
14
23
|
authenticate_spree_user!
|
|
@@ -17,7 +26,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
|
17
26
|
respond_to do |format|
|
|
18
27
|
format.html {
|
|
19
28
|
flash[:success] = Spree.t(:logged_in_succesfully)
|
|
20
|
-
redirect_back_or_default(
|
|
29
|
+
redirect_back_or_default(after_sign_in_redirect(spree_current_user))
|
|
21
30
|
}
|
|
22
31
|
format.js {
|
|
23
32
|
render json: { user: spree_current_user,
|
|
@@ -54,4 +63,24 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
|
54
63
|
redirect_to(session["spree_user_return_to"] || default)
|
|
55
64
|
session["spree_user_return_to"] = nil
|
|
56
65
|
end
|
|
66
|
+
|
|
67
|
+
def after_sign_in_redirect(resource_or_scope)
|
|
68
|
+
stored_location_for(resource_or_scope) || account_path
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def respond_to_on_destroy
|
|
72
|
+
# We actually need to hardcode this as Rails default responder doesn't
|
|
73
|
+
# support returning empty response on GET request
|
|
74
|
+
respond_to do |format|
|
|
75
|
+
format.all { head :no_content }
|
|
76
|
+
format.any(*navigational_formats) { redirect_to after_sign_out_redirect(resource_name) }
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def after_sign_out_redirect(resource_or_scope)
|
|
81
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
|
82
|
+
router_name = Devise.mappings[scope].router_name
|
|
83
|
+
context = router_name ? send(router_name) : self
|
|
84
|
+
context.respond_to?(:login_path) ? context.login_path : "/"
|
|
85
|
+
end
|
|
57
86
|
end
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
class UserMailer < BaseMailer
|
|
3
3
|
def reset_password_instructions(user, token, *_args)
|
|
4
|
-
|
|
4
|
+
current_store_id = _args.inject(:merge)[:current_store_id]
|
|
5
|
+
@current_store = Spree::Store.find(current_store_id) || Spree::Store.current
|
|
6
|
+
@locale = @current_store.has_attribute?(:default_locale) ? @current_store.default_locale : I18n.default_locale
|
|
7
|
+
I18n.locale = @locale if @locale.present?
|
|
8
|
+
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @current_store.url)
|
|
5
9
|
|
|
6
|
-
mail to: user.email, from: from_address, subject:
|
|
10
|
+
mail to: user.email, from: from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])
|
|
7
11
|
end
|
|
8
12
|
|
|
9
13
|
def confirmation_instructions(user, token, _opts = {})
|
data/app/models/spree/user.rb
CHANGED
|
@@ -27,6 +27,23 @@ module Spree
|
|
|
27
27
|
has_spree_role?('admin')
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def self.send_reset_password_instructions(attributes={}, current_store)
|
|
31
|
+
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
|
|
32
|
+
recoverable.send_reset_password_instructions(current_store) if recoverable.persisted?
|
|
33
|
+
recoverable
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def send_reset_password_instructions(current_store)
|
|
37
|
+
token = set_reset_password_token
|
|
38
|
+
send_reset_password_instructions_notification(token, current_store.id)
|
|
39
|
+
|
|
40
|
+
token
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def send_reset_password_instructions_notification(token, current_store_id)
|
|
44
|
+
send_devise_notification(:reset_password_instructions, token, { current_store_id: current_store_id })
|
|
45
|
+
end
|
|
46
|
+
|
|
30
47
|
protected
|
|
31
48
|
|
|
32
49
|
def password_required?
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Account
|
|
3
|
+
class Update
|
|
4
|
+
prepend Spree::ServiceModule::Base
|
|
5
|
+
|
|
6
|
+
def call(user:, user_params: nil)
|
|
7
|
+
user_params ||= {}
|
|
8
|
+
|
|
9
|
+
if user.update(user_params)
|
|
10
|
+
success(user)
|
|
11
|
+
else
|
|
12
|
+
failure(user)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
If you did not make this request, simply ignore this email.
|
|
3
|
-
|
|
4
|
-
If you did make this request just click the link below:
|
|
1
|
+
<%= Spree.t('user_mailer.reset_password_instructions.instructions_1') %>
|
|
5
2
|
|
|
6
3
|
<%= @edit_password_reset_url %>
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
If you continue to have problems please feel free to contact us.
|
|
10
|
-
|
|
5
|
+
<%= Spree.t('user_mailer.reset_password_instructions.instructions_2') %>
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
|
|
3
|
+
<div class="container user-passwords">
|
|
4
|
+
<div class="row">
|
|
5
|
+
<div class="col-lg-6 offset-lg-3">
|
|
6
|
+
<div class="card mb-3 user-passwords-no-border">
|
|
7
|
+
<h3 class="spree-mb-large spree-mt-large spree-header"><%= Spree.t(:change_your_password) %></h3>
|
|
8
|
+
<div class="card-body">
|
|
9
|
+
<%= form_for @spree_user, as: :spree_user, url: spree.update_password_path, method: :put do |f| %>
|
|
10
|
+
<div class="form-group">
|
|
11
|
+
<%= f.label :password, Spree.t(:password), class: 'spree-flat-label' %>
|
|
12
|
+
<%= f.password_field :password, class: "spree-flat-input" %>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="form-group">
|
|
15
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password), class: 'spree-flat-label' %>
|
|
16
|
+
<%= f.password_field :password_confirmation, class: "spree-flat-input" %>
|
|
17
|
+
</div>
|
|
18
|
+
<%= f.hidden_field :reset_password_token %>
|
|
19
|
+
<%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block spree-btn mt-2' %>
|
|
20
|
+
<% end %>
|
|
16
21
|
</div>
|
|
17
|
-
|
|
18
|
-
<%= f.submit Spree.t(:update), :class => 'btn btn-lg btn-success btn-block' %>
|
|
19
|
-
<% end %>
|
|
22
|
+
</div>
|
|
20
23
|
</div>
|
|
21
24
|
</div>
|
|
22
25
|
</div>
|