solidus_auth_devise 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_auth_devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +88 -0
- data/Rakefile +21 -0
- data/app/controllers/metal_decorator.rb +6 -0
- data/app/mailers/spree/user_mailer.rb +15 -0
- data/app/models/spree/auth_configuration.rb +7 -0
- data/app/models/spree/user.rb +50 -0
- data/app/overrides/auth_shared_login_bar.rb +7 -0
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +4 -0
- data/bin/rails +7 -0
- data/config/initializers/devise.rb +137 -0
- data/config/initializers/warden.rb +14 -0
- data/config/locales/de.yml +49 -0
- data/config/locales/en.yml +55 -0
- data/config/locales/es.yml +49 -0
- data/config/locales/fr.yml +49 -0
- data/config/locales/it.yml +76 -0
- data/config/locales/nl.yml +49 -0
- data/config/locales/pt-BR.yml +51 -0
- data/config/locales/tr.yml +49 -0
- data/config/routes.rb +48 -0
- data/db/default/users.rb +83 -0
- data/db/migrate/20101026184949_create_users.rb +29 -0
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +37 -0
- data/db/migrate/20101214150824_convert_user_remember_field.rb +11 -0
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +8 -0
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +9 -0
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +7 -0
- data/db/seeds.rb +5 -0
- data/lib/assets/javascripts/spree/backend/solidus_auth.js +1 -0
- data/lib/assets/javascripts/spree/frontend/solidus_auth.js +1 -0
- data/lib/assets/stylesheets/spree/backend/solidus_auth.css +3 -0
- data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +3 -0
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +26 -0
- data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +20 -0
- data/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb +3 -0
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +15 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +45 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +47 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +47 -0
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +21 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +53 -0
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +72 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +53 -0
- data/lib/controllers/frontend/spree/users_controller.rb +57 -0
- data/lib/generators/spree/auth/install/install_generator.rb +26 -0
- data/lib/generators/spree/auth/install/templates/config/initializers/devise.rb +1 -0
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +5 -0
- data/lib/spree/auth/devise.rb +20 -0
- data/lib/spree/auth/engine.rb +77 -0
- data/lib/spree/authentication_helpers.rb +26 -0
- data/lib/tasks/auth.rake +9 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +15 -0
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +17 -0
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +31 -0
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +13 -0
- data/lib/views/frontend/spree/checkout/registration.html.erb +22 -0
- data/lib/views/frontend/spree/shared/_flashes.html.erb +9 -0
- data/lib/views/frontend/spree/shared/_login.html.erb +18 -0
- data/lib/views/frontend/spree/shared/_login_bar.html.erb +6 -0
- data/lib/views/frontend/spree/shared/_user_form.html.erb +17 -0
- data/lib/views/frontend/spree/user_mailer/confirmation_instructions.text.erb +5 -0
- data/lib/views/frontend/spree/user_mailer/reset_password_instructions.text.erb +10 -0
- data/lib/views/frontend/spree/user_passwords/edit.html.erb +17 -0
- data/lib/views/frontend/spree/user_passwords/new.html.erb +17 -0
- data/lib/views/frontend/spree/user_registrations/new.html.erb +21 -0
- data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/frontend/spree/user_sessions/new.html.erb +13 -0
- data/lib/views/frontend/spree/users/edit.html.erb +14 -0
- data/lib/views/frontend/spree/users/show.html.erb +43 -0
- data/solidus_auth_devise.gemspec +42 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +14 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +141 -0
- data/spec/controllers/spree/products_controller_spec.rb +21 -0
- data/spec/controllers/spree/user_passwords_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_registrations_controller_spec.rb +13 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +56 -0
- data/spec/controllers/spree/users_controller_spec.rb +38 -0
- data/spec/factories/confirmed_user.rb +7 -0
- data/spec/features/account_spec.rb +58 -0
- data/spec/features/admin/orders_spec.rb +29 -0
- data/spec/features/admin/password_reset_spec.rb +24 -0
- data/spec/features/admin/payment_methods_spec.rb +16 -0
- data/spec/features/admin/products_spec.rb +9 -0
- data/spec/features/admin/sign_in_spec.rb +44 -0
- data/spec/features/admin/sign_out_spec.rb +22 -0
- data/spec/features/admin_permissions_spec.rb +46 -0
- data/spec/features/change_email_spec.rb +24 -0
- data/spec/features/checkout_spec.rb +165 -0
- data/spec/features/confirmation_spec.rb +28 -0
- data/spec/features/order_spec.rb +62 -0
- data/spec/features/password_reset_spec.rb +24 -0
- data/spec/features/sign_in_spec.rb +52 -0
- data/spec/features/sign_out_spec.rb +25 -0
- data/spec/features/sign_up_spec.rb +30 -0
- data/spec/mailers/user_mailer_spec.rb +46 -0
- data/spec/models/order_spec.rb +26 -0
- data/spec/models/user_spec.rb +58 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/ability.rb +15 -0
- data/spec/support/authentication_helpers.rb +14 -0
- data/spec/support/capybara.rb +7 -0
- data/spec/support/confirm_helpers.rb +11 -0
- data/spec/support/database_cleaner.rb +18 -0
- data/spec/support/email.rb +5 -0
- data/spec/support/factory_girl.rb +5 -0
- data/spec/support/spree.rb +26 -0
- metadata +452 -0
data/db/default/users.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
# see last line where we create an admin if there is none, asking for email and password
|
4
|
+
def prompt_for_admin_password
|
5
|
+
if ENV['ADMIN_PASSWORD']
|
6
|
+
password = ENV['ADMIN_PASSWORD'].dup
|
7
|
+
say "Admin Password #{password}"
|
8
|
+
else
|
9
|
+
password = ask('Password [spree123]: ') do |q|
|
10
|
+
q.echo = false
|
11
|
+
q.validate = /^(|.{5,40})$/
|
12
|
+
q.responses[:not_valid] = 'Invalid password. Must be at least 5 characters long.'
|
13
|
+
q.whitespace = :strip
|
14
|
+
end
|
15
|
+
password = 'spree123' if password.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
password
|
19
|
+
end
|
20
|
+
|
21
|
+
def prompt_for_admin_email
|
22
|
+
if ENV['ADMIN_EMAIL']
|
23
|
+
email = ENV['ADMIN_EMAIL'].dup
|
24
|
+
say "Admin User #{email}"
|
25
|
+
else
|
26
|
+
email = ask('Email [spree@example.com]: ') do |q|
|
27
|
+
q.echo = true
|
28
|
+
q.whitespace = :strip
|
29
|
+
end
|
30
|
+
email = 'spree@example.com' if email.blank?
|
31
|
+
end
|
32
|
+
|
33
|
+
email
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_admin_user
|
37
|
+
if ENV['AUTO_ACCEPT']
|
38
|
+
password = 'spree123'
|
39
|
+
email = 'spree@example.com'
|
40
|
+
else
|
41
|
+
puts 'Create the admin user (press enter for defaults).'
|
42
|
+
#name = prompt_for_admin_name unless name
|
43
|
+
email = prompt_for_admin_email
|
44
|
+
password = prompt_for_admin_password
|
45
|
+
end
|
46
|
+
attributes = {
|
47
|
+
:password => password,
|
48
|
+
:password_confirmation => password,
|
49
|
+
:email => email,
|
50
|
+
:login => email
|
51
|
+
}
|
52
|
+
|
53
|
+
load 'spree/user.rb'
|
54
|
+
|
55
|
+
if Spree::User.find_by_email(email)
|
56
|
+
say "\nWARNING: There is already a user with the email: #{email}, so no account changes were made. If you wish to create an additional admin user, please run rake spree_auth:admin:create again with a different email.\n\n"
|
57
|
+
else
|
58
|
+
admin = Spree::User.new(attributes)
|
59
|
+
if admin.save
|
60
|
+
role = Spree::Role.find_or_create_by(name: 'admin')
|
61
|
+
admin.spree_roles << role
|
62
|
+
admin.save
|
63
|
+
admin.generate_spree_api_key!
|
64
|
+
say "Done!"
|
65
|
+
else
|
66
|
+
say "There was some problems with persisting new admin user:"
|
67
|
+
admin.errors.full_messages.each do |error|
|
68
|
+
say error
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if Spree::User.admin.empty?
|
75
|
+
create_admin_user
|
76
|
+
else
|
77
|
+
puts 'Admin user has already been previously created.'
|
78
|
+
if agree('Would you like to create a new admin user? (yes/no)')
|
79
|
+
create_admin_user
|
80
|
+
else
|
81
|
+
puts 'No admin user created.'
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("spree_users")
|
4
|
+
create_table "spree_users", :force => true do |t|
|
5
|
+
t.string "crypted_password", :limit => 128
|
6
|
+
t.string "salt", :limit => 128
|
7
|
+
t.string "email"
|
8
|
+
t.string "remember_token"
|
9
|
+
t.string "remember_token_expires_at"
|
10
|
+
t.string "persistence_token"
|
11
|
+
t.string "single_access_token"
|
12
|
+
t.string "perishable_token"
|
13
|
+
t.integer "login_count", :default => 0, :null => false
|
14
|
+
t.integer "failed_login_count", :default => 0, :null => false
|
15
|
+
t.datetime "last_request_at"
|
16
|
+
t.datetime "current_login_at"
|
17
|
+
t.datetime "last_login_at"
|
18
|
+
t.string "current_login_ip"
|
19
|
+
t.string "last_login_ip"
|
20
|
+
t.string "login"
|
21
|
+
t.integer "ship_address_id"
|
22
|
+
t.integer "bill_address_id"
|
23
|
+
t.datetime "created_at", :null => false
|
24
|
+
t.datetime "updated_at", :null => false
|
25
|
+
t.string "openid_identifier"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class RenameColumnsForDevise < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
return if column_exists?(:spree_users, :password_salt)
|
4
|
+
rename_column :spree_users, :crypted_password, :encrypted_password
|
5
|
+
rename_column :spree_users, :salt, :password_salt
|
6
|
+
rename_column :spree_users, :remember_token_expires_at, :remember_created_at
|
7
|
+
rename_column :spree_users, :login_count, :sign_in_count
|
8
|
+
rename_column :spree_users, :failed_login_count, :failed_attempts
|
9
|
+
rename_column :spree_users, :single_access_token, :reset_password_token
|
10
|
+
rename_column :spree_users, :current_login_at, :current_sign_in_at
|
11
|
+
rename_column :spree_users, :last_login_at, :last_sign_in_at
|
12
|
+
rename_column :spree_users, :current_login_ip, :current_sign_in_ip
|
13
|
+
rename_column :spree_users, :last_login_ip, :last_sign_in_ip
|
14
|
+
add_column :spree_users, :authentication_token, :string
|
15
|
+
add_column :spree_users, :unlock_token, :string
|
16
|
+
add_column :spree_users, :locked_at, :datetime
|
17
|
+
remove_column :spree_users, :openid_identifier
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
remove_column :spree_users, :authentication_token
|
22
|
+
remove_column :spree_users, :locked_at
|
23
|
+
remove_column :spree_users, :unlock_token
|
24
|
+
rename_column :spree_users, :last_sign_in_ip, :last_login_ip
|
25
|
+
rename_column :spree_users, :current_sign_in_ip, :current_login_ip
|
26
|
+
rename_column :spree_users, :last_sign_in_at, :last_login_at
|
27
|
+
rename_column :spree_users, :current_sign_in_at, :current_login_at
|
28
|
+
rename_column :spree_users, :reset_password_token, :single_access_token
|
29
|
+
rename_column :spree_users, :failed_attempts, :failed_login_count
|
30
|
+
rename_column :spree_users, :sign_in_count, :login_count
|
31
|
+
rename_column :spree_users, :remember_created_at, :remember_token_expires_at
|
32
|
+
rename_column :spree_users, :password_salt, :salt
|
33
|
+
rename_column :spree_users, :encrypted_password, :crypted_password
|
34
|
+
add_column :spree_users, :unlock_token, :string
|
35
|
+
add_column :spree_users, :openid_identifier, :string
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ConvertUserRememberField < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
remove_column :spree_users, :remember_created_at
|
4
|
+
add_column :spree_users, :remember_created_at, :datetime
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :spree_users, :remember_created_at
|
9
|
+
add_column :spree_users, :remember_created_at, :string
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class AddResetPasswordSentAtToSpreeUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
Spree::User.reset_column_information
|
4
|
+
unless Spree::User.column_names.include?("reset_password_sent_at")
|
5
|
+
add_column :spree_users, :reset_password_sent_at, :datetime
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= require spree/backend
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require spree/frontend
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Spree::Admin::BaseController.class_eval do
|
2
|
+
|
3
|
+
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
|
4
|
+
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
|
5
|
+
# to access the requested action. For example, a popup window might simply close itself.
|
6
|
+
def unauthorized
|
7
|
+
if try_spree_current_user
|
8
|
+
flash[:error] = Spree.t(:authorization_failure)
|
9
|
+
redirect_to spree.admin_unauthorized_path
|
10
|
+
else
|
11
|
+
store_location
|
12
|
+
redirect_to spree.admin_login_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def model_class
|
19
|
+
const_name = controller_name.classify
|
20
|
+
if Spree.const_defined?(const_name, false)
|
21
|
+
return "Spree::#{const_name}".constantize
|
22
|
+
end
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Spree::Admin::OrdersController.class_eval do
|
2
|
+
before_filter :check_authorization
|
3
|
+
|
4
|
+
private
|
5
|
+
def load_order_action
|
6
|
+
[:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart]
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_authorization
|
10
|
+
action = params[:action].to_sym
|
11
|
+
if load_order_action.include?(action)
|
12
|
+
load_order
|
13
|
+
session[:access_token] ||= params[:token]
|
14
|
+
resource = @order || Spree::Order.new
|
15
|
+
authorize! action, resource, session[:access_token]
|
16
|
+
else
|
17
|
+
authorize! :index, Spree::Order
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Spree::Admin::Orders::CustomerDetailsController.class_eval do
|
2
|
+
before_filter :check_authorization
|
3
|
+
|
4
|
+
private
|
5
|
+
def check_authorization
|
6
|
+
load_order
|
7
|
+
session[:access_token] ||= params[:token]
|
8
|
+
|
9
|
+
resource = @order
|
10
|
+
action = params[:action].to_sym
|
11
|
+
action = :edit if action == :show # show route renders :edit for this controller
|
12
|
+
|
13
|
+
authorize! action, resource, session[:access_token]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
2
|
+
helper 'spree/base'
|
3
|
+
|
4
|
+
include Spree::Core::ControllerHelpers::Auth
|
5
|
+
include Spree::Core::ControllerHelpers::Common
|
6
|
+
include Spree::Core::ControllerHelpers::SSL
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
8
|
+
|
9
|
+
helper 'spree/admin/navigation'
|
10
|
+
helper 'spree/admin/tables'
|
11
|
+
layout 'spree/layouts/admin'
|
12
|
+
|
13
|
+
ssl_required
|
14
|
+
|
15
|
+
# Overridden due to bug in Devise.
|
16
|
+
# respond_with resource, :location => new_session_path(resource_name)
|
17
|
+
# is generating bad url /session/new.user
|
18
|
+
#
|
19
|
+
# overridden to:
|
20
|
+
# respond_with resource, :location => spree.login_path
|
21
|
+
#
|
22
|
+
def create
|
23
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
24
|
+
|
25
|
+
if resource.errors.empty?
|
26
|
+
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
27
|
+
respond_with resource, :location => spree.admin_login_path
|
28
|
+
else
|
29
|
+
respond_with_navigational(resource) { render :new }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Devise::PasswordsController allows for blank passwords.
|
34
|
+
# Silly Devise::PasswordsController!
|
35
|
+
# Fixes spree/spree#2190.
|
36
|
+
def update
|
37
|
+
if params[:spree_user][:password].blank?
|
38
|
+
set_flash_message(:error, :cannot_be_blank)
|
39
|
+
render :edit
|
40
|
+
else
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Spree::Admin::UserSessionsController < Devise::SessionsController
|
2
|
+
helper 'spree/base'
|
3
|
+
|
4
|
+
include Spree::Core::ControllerHelpers::Auth
|
5
|
+
include Spree::Core::ControllerHelpers::Common
|
6
|
+
include Spree::Core::ControllerHelpers::SSL
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
8
|
+
|
9
|
+
helper 'spree/admin/navigation'
|
10
|
+
helper 'spree/admin/tables'
|
11
|
+
layout 'spree/layouts/admin'
|
12
|
+
|
13
|
+
ssl_required :new, :create, :destroy, :update
|
14
|
+
|
15
|
+
def create
|
16
|
+
authenticate_spree_user!
|
17
|
+
|
18
|
+
if spree_user_signed_in?
|
19
|
+
respond_to do |format|
|
20
|
+
format.html {
|
21
|
+
flash[:success] = Spree.t(:logged_in_succesfully)
|
22
|
+
redirect_back_or_default(after_sign_in_path_for(spree_current_user))
|
23
|
+
}
|
24
|
+
format.js {
|
25
|
+
user = resource.record
|
26
|
+
render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json
|
27
|
+
}
|
28
|
+
end
|
29
|
+
else
|
30
|
+
flash.now[:error] = t('devise.failure.invalid')
|
31
|
+
render :new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def authorization_failure
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def accurate_title
|
40
|
+
Spree.t(:login)
|
41
|
+
end
|
42
|
+
|
43
|
+
def redirect_back_or_default(default)
|
44
|
+
redirect_to(session["spree_user_return_to"] || default)
|
45
|
+
session["spree_user_return_to"] = nil
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spree/core/validators/email'
|
2
|
+
Spree::CheckoutController.class_eval do
|
3
|
+
before_filter :check_authorization
|
4
|
+
before_filter :check_registration, :except => [:registration, :update_registration]
|
5
|
+
|
6
|
+
def registration
|
7
|
+
@user = Spree::User.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def update_registration
|
11
|
+
if params[:order][:email] =~ Devise.email_regexp && current_order.update_attribute(:email, params[:order][:email])
|
12
|
+
redirect_to spree.checkout_path
|
13
|
+
else
|
14
|
+
flash[:registration_error] = t(:email_is_invalid, :scope => [:errors, :messages])
|
15
|
+
@user = Spree::User.new
|
16
|
+
render 'registration'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def order_params
|
22
|
+
params[:order] ? params.require(:order).permit(:email) : {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def skip_state_validation?
|
26
|
+
%w(registration update_registration).include?(params[:action])
|
27
|
+
end
|
28
|
+
|
29
|
+
def check_authorization
|
30
|
+
authorize!(:edit, current_order, cookies.signed[:guest_token])
|
31
|
+
end
|
32
|
+
|
33
|
+
# Introduces a registration step whenever the +registration_step+ preference is true.
|
34
|
+
def check_registration
|
35
|
+
return unless Spree::Auth::Config[:registration_step]
|
36
|
+
return if spree_current_user or current_order.email
|
37
|
+
store_location
|
38
|
+
redirect_to spree.checkout_registration_path
|
39
|
+
end
|
40
|
+
|
41
|
+
# Overrides the equivalent method defined in Spree::Core. This variation of the method will ensure that users
|
42
|
+
# are redirected to the tokenized order url unless authenticated as a registered user.
|
43
|
+
def completion_route
|
44
|
+
return spree.order_path(@order) if spree_current_user
|
45
|
+
spree.token_order_path(@order, @order.guest_token)
|
46
|
+
end
|
47
|
+
end
|