spree_auth_devise 4.0.0 → 4.3.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.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +33 -37
- data/Appraisals +3 -14
- data/Gemfile +1 -1
- 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 +38 -0
- data/app/controllers/spree/user_passwords_controller.rb +9 -1
- data/app/controllers/spree/user_registrations_controller.rb +34 -1
- data/app/controllers/spree/user_sessions_controller.rb +23 -1
- data/app/mailers/spree/user_mailer.rb +11 -4
- data/app/models/spree/user.rb +42 -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.html.erb +20 -0
- data/app/views/spree/user_mailer/confirmation_instructions.text.erb +8 -5
- data/app/views/spree/user_mailer/reset_password_instructions.html.erb +20 -0
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +7 -5
- 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 +16 -0
- data/config/locales/en.yml +21 -6
- data/config/locales/zh-TW.yml +58 -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_2.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 +3 -2
- data/lib/controllers/frontend/spree/users_controller.rb +4 -4
- 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/spree_auth_devise.rb +0 -1
- 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 +40 -65
- data/spec/features/confirmation_spec.rb +4 -6
- 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 +4 -4
- data/spec/models/user_spec.rb +10 -8
- 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/spec_helper.rb +7 -22
- data/spree_auth_devise.gemspec +14 -27
- metadata +35 -337
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +0 -4
- 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_5.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: 8b4a6cf62ece3fa34c1fd91a3c20bfeb10ec5a658d15f28d9bd250f4e730314b
|
4
|
+
data.tar.gz: 4b16aef83401692f7468b7090e3f4e4184b3f45c4761655a256c7c269b6f1a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 623b257e40aff603cec630bab6e2fb87b878fcf8fd42f9b462282234fb0ad885caaada7236ef9da8248de71bc6046041550145a0542c7ae6e15fea718802d27e
|
7
|
+
data.tar.gz: cd851d1dd8a27b4c3dd9c27f4f3e8ad39e152551fc5e5429bd125c5f714d34f59a623954485f96f410f0f6c9afdf9f287602af809377af79cfad4dd03b3e0a34
|
@@ -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,47 @@
|
|
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.
|
20
|
-
-
|
21
|
-
|
18
|
+
- 2.7
|
19
|
+
- 3.0
|
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
|
-
|
33
|
-
|
34
|
-
|
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
|
+
exclude:
|
31
|
+
- rvm: 3.0
|
32
|
+
gemfile: gemfiles/spree_4_1.gemfile
|
33
|
+
allow_failures:
|
34
|
+
- gemfile: gemfiles/spree_master.gemfile
|
43
35
|
|
44
36
|
before_install:
|
45
37
|
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
46
|
-
|
47
|
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
38
|
+
|
39
|
+
before_script:
|
40
|
+
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
|
41
|
+
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
|
42
|
+
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
|
43
|
+
- unzip chromedriver_linux64.zip -d ~/bin
|
44
|
+
|
45
|
+
script:
|
46
|
+
- bundle exec rake test_app
|
47
|
+
- 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,44 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
6
6
|
include Spree::Core::ControllerHelpers::Order
|
7
7
|
include Spree::Core::ControllerHelpers::Store
|
8
8
|
|
9
|
+
before_action :set_current_order
|
10
|
+
|
11
|
+
if Spree.version.to_f >= 4.2
|
12
|
+
# POST /resource/confirmation
|
13
|
+
def create
|
14
|
+
self.resource = resource_class.send_confirmation_instructions(resource_params, current_store)
|
15
|
+
yield resource if block_given?
|
16
|
+
|
17
|
+
if successfully_sent?(resource)
|
18
|
+
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
|
19
|
+
else
|
20
|
+
respond_with(resource)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
26
|
+
def show
|
27
|
+
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
28
|
+
yield resource if block_given?
|
29
|
+
|
30
|
+
if resource.errors.empty?
|
31
|
+
set_flash_message!(:notice, :confirmed)
|
32
|
+
respond_with_navigational(resource) do
|
33
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
34
|
+
end
|
35
|
+
elsif resource.confirmed?
|
36
|
+
set_flash_message(:error, :already_confirmed)
|
37
|
+
respond_with_navigational(resource) do
|
38
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
respond_with_navigational(resource.errors, status: :unprocessable_entity) do
|
42
|
+
render :new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
9
47
|
protected
|
10
48
|
|
11
49
|
def after_confirmation_path_for(resource_name, resource)
|
@@ -10,6 +10,8 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
10
10
|
include SpreeI18n::ControllerLocaleHelper
|
11
11
|
end
|
12
12
|
|
13
|
+
before_action :set_current_order
|
14
|
+
|
13
15
|
# Overridden due to bug in Devise.
|
14
16
|
# respond_with resource, :location => new_session_path(resource_name)
|
15
17
|
# is generating bad url /session/new.user
|
@@ -18,7 +20,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
18
20
|
# respond_with resource, :location => spree.login_path
|
19
21
|
#
|
20
22
|
def create
|
21
|
-
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
23
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name], current_store)
|
22
24
|
|
23
25
|
if resource.errors.empty?
|
24
26
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
@@ -51,4 +53,10 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
51
53
|
def new_session_path(resource_name)
|
52
54
|
spree.send("new_#{resource_name}_session_path")
|
53
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def accurate_title
|
60
|
+
Spree.t(:reset_password)
|
61
|
+
end
|
54
62
|
end
|
@@ -11,6 +11,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before_action :check_permissions, only: [:edit, :update]
|
14
|
+
before_action :set_current_order
|
14
15
|
skip_before_action :require_no_authentication
|
15
16
|
|
16
17
|
# GET /resource/sign_up
|
@@ -22,6 +23,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
22
23
|
# POST /resource/sign_up
|
23
24
|
def create
|
24
25
|
@user = build_resource(spree_user_params)
|
26
|
+
resource.skip_confirmation_notification! if Spree::Auth::Config[:confirmable]
|
25
27
|
resource_saved = resource.save
|
26
28
|
yield resource if block_given?
|
27
29
|
if resource_saved
|
@@ -29,10 +31,12 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
29
31
|
set_flash_message :notice, :signed_up
|
30
32
|
sign_up(resource_name, resource)
|
31
33
|
session[:spree_user_signup] = true
|
32
|
-
|
34
|
+
resource.send_confirmation_instructions(current_store) if Spree::Auth::Config[:confirmable]
|
35
|
+
redirect_to_checkout_or_account_path(resource)
|
33
36
|
else
|
34
37
|
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}"
|
35
38
|
expire_data_after_sign_in!
|
39
|
+
resource.send_confirmation_instructions(current_store) if Spree::Auth::Config[:confirmable]
|
36
40
|
respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
37
41
|
end
|
38
42
|
else
|
@@ -75,9 +79,38 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
75
79
|
'devise.user_registrations'
|
76
80
|
end
|
77
81
|
|
82
|
+
def after_sign_up_path_for(resource)
|
83
|
+
after_sign_in_redirect(resource) if is_navigational_format?
|
84
|
+
end
|
85
|
+
|
86
|
+
def after_inactive_sign_up_path_for(resource)
|
87
|
+
scope = Devise::Mapping.find_scope!(resource)
|
88
|
+
router_name = Devise.mappings[scope].router_name
|
89
|
+
context = router_name ? send(router_name) : self
|
90
|
+
context.respond_to?(:login_path) ? context.login_path : "/login"
|
91
|
+
end
|
92
|
+
|
78
93
|
private
|
79
94
|
|
95
|
+
def accurate_title
|
96
|
+
Spree.t(:sign_up)
|
97
|
+
end
|
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
|
@@ -10,6 +10,8 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
10
10
|
include SpreeI18n::ControllerLocaleHelper
|
11
11
|
end
|
12
12
|
|
13
|
+
before_action :set_current_order
|
14
|
+
|
13
15
|
def create
|
14
16
|
authenticate_spree_user!
|
15
17
|
|
@@ -17,7 +19,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
17
19
|
respond_to do |format|
|
18
20
|
format.html {
|
19
21
|
flash[:success] = Spree.t(:logged_in_succesfully)
|
20
|
-
redirect_back_or_default(
|
22
|
+
redirect_back_or_default(after_sign_in_redirect(spree_current_user))
|
21
23
|
}
|
22
24
|
format.js {
|
23
25
|
render json: { user: spree_current_user,
|
@@ -54,4 +56,24 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
54
56
|
redirect_to(session["spree_user_return_to"] || default)
|
55
57
|
session["spree_user_return_to"] = nil
|
56
58
|
end
|
59
|
+
|
60
|
+
def after_sign_in_redirect(resource_or_scope)
|
61
|
+
stored_location_for(resource_or_scope) || account_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def respond_to_on_destroy
|
65
|
+
# We actually need to hardcode this as Rails default responder doesn't
|
66
|
+
# support returning empty response on GET request
|
67
|
+
respond_to do |format|
|
68
|
+
format.all { head :no_content }
|
69
|
+
format.any(*navigational_formats) { redirect_to after_sign_out_redirect(resource_name) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def after_sign_out_redirect(resource_or_scope)
|
74
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
75
|
+
router_name = Devise.mappings[scope].router_name
|
76
|
+
context = router_name ? send(router_name) : self
|
77
|
+
context.respond_to?(:login_path) ? context.login_path : "/"
|
78
|
+
end
|
57
79
|
end
|