spree_auth_devise 1.3.1 → 3.0.5
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +11 -0
- data/Gemfile +5 -0
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +86 -10
- data/Rakefile +15 -0
- data/Versionfile +5 -0
- data/app/controllers/metal_decorator.rb +6 -0
- data/app/mailers/spree/user_mailer.rb +12 -5
- data/app/models/spree/auth_configuration.rb +1 -0
- data/app/models/spree/user.rb +17 -50
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +4 -0
- data/bin/rails +7 -0
- data/circle.yml +11 -0
- data/config.ru +4 -0
- data/config/initializers/devise.rb +3 -8
- data/config/initializers/warden.rb +14 -0
- data/config/locales/de.yml +40 -37
- data/config/locales/en.yml +48 -39
- 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 +41 -46
- data/config/locales/pt-BR.yml +51 -0
- data/config/locales/tr.yml +49 -0
- data/config/routes.rb +32 -15
- data/db/default/users.rb +13 -6
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +7 -0
- data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +1 -0
- data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +1 -0
- data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +3 -0
- data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +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/{app/controllers → lib/controllers/backend}/spree/admin/admin_resource_controller_decorator.rb +0 -0
- data/{app/controllers/spree/admin/admin_orders_controller_decorator.rb → lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb} +3 -2
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +42 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +53 -0
- data/{app/controllers → lib/controllers/frontend}/spree/checkout_controller_decorator.rb +8 -15
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +14 -0
- data/{app/controllers → lib/controllers/frontend}/spree/user_passwords_controller.rb +10 -9
- data/{app/controllers → lib/controllers/frontend}/spree/user_registrations_controller.rb +18 -15
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +46 -0
- data/{app/controllers → lib/controllers/frontend}/spree/users_controller.rb +13 -9
- 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/spree/auth.rb +2 -1
- data/lib/spree/auth/devise.rb +7 -0
- data/lib/spree/auth/engine.rb +57 -2
- data/lib/spree/authentication_helpers.rb +1 -1
- data/lib/spree_auth_devise.rb +3 -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 +38 -0
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +33 -0
- data/lib/views/backend/spree/layouts/login.html.erb +25 -0
- data/lib/views/frontend/spree/checkout/_new_user.html.erb +20 -0
- data/lib/views/frontend/spree/checkout/registration.html.erb +27 -0
- data/{app/views → lib/views/frontend}/spree/shared/_flashes.html.erb +0 -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 +13 -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 +22 -0
- data/lib/views/frontend/spree/user_passwords/new.html.erb +21 -0
- data/lib/views/frontend/spree/user_registrations/new.html.erb +22 -0
- data/lib/views/frontend/spree/user_sessions/new.html.erb +20 -0
- data/lib/views/frontend/spree/users/edit.html.erb +17 -0
- data/lib/views/frontend/spree/users/show.html.erb +43 -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 +28 -0
- data/spec/features/admin/password_reset_spec.rb +24 -0
- data/spec/features/admin/products_spec.rb +9 -0
- data/spec/features/admin/sign_in_spec.rb +45 -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 +160 -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 +54 -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 +24 -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
- data/spree_auth_devise.gemspec +48 -0
- metadata +441 -79
- data/app/assets/javascripts/admin/spree_auth.js +0 -1
- data/app/assets/javascripts/store/spree_auth.js +0 -1
- data/app/assets/stylesheets/admin/spree_auth.css +0 -3
- data/app/assets/stylesheets/store/spree_auth.css +0 -3
- data/app/controllers/spree/admin/admin_controller_decorator.rb +0 -7
- data/app/controllers/spree/admin/admin_users_controller_decorator.rb +0 -21
- data/app/controllers/spree/admin/users_controller.rb +0 -77
- data/app/controllers/spree/base_controller_decorator.rb +0 -18
- data/app/controllers/spree/orders_controller_decorator.rb +0 -15
- data/app/controllers/spree/user_sessions_controller.rb +0 -54
- data/app/helpers/spree/users_helper.rb +0 -15
- data/app/models/spree/current_order_decorator.rb +0 -12
- data/app/overrides/admin_tab.rb +0 -6
- data/app/overrides/auth_admin_login_navigation_bar.rb +0 -5
- data/app/overrides/auth_user_login_form.rb +0 -6
- data/app/views/spree/admin/users/_form.html.erb +0 -37
- data/app/views/spree/admin/users/edit.html.erb +0 -28
- data/app/views/spree/admin/users/index.html.erb +0 -53
- data/app/views/spree/admin/users/new.html.erb +0 -23
- data/app/views/spree/admin/users/show.html.erb +0 -21
- data/app/views/spree/layouts/admin/_login_nav.html.erb +0 -8
- data/app/views/spree/shared/_login.html.erb +0 -20
- data/app/views/spree/shared/_login_bar.html.erb +0 -6
- data/app/views/spree/shared/_user_form.html.erb +0 -17
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +0 -10
- data/app/views/spree/user_passwords/edit.html.erb +0 -15
- data/app/views/spree/user_passwords/new.html.erb +0 -15
- data/app/views/spree/user_registrations/new.html.erb +0 -22
- data/app/views/spree/user_sessions/authorization_failure.html.erb +0 -4
- data/app/views/spree/user_sessions/new.html.erb +0 -13
- data/app/views/spree/users/edit.html.erb +0 -11
- data/app/views/spree/users/show.html.erb +0 -43
- data/config/initializers/spree.rb +0 -1
data/config/routes.rb
CHANGED
|
@@ -1,31 +1,48 @@
|
|
|
1
|
-
Spree::Core::Engine.
|
|
2
|
-
devise_for :
|
|
1
|
+
Spree::Core::Engine.add_routes do
|
|
2
|
+
devise_for :spree_user,
|
|
3
3
|
:class_name => 'Spree::User',
|
|
4
4
|
:controllers => { :sessions => 'spree/user_sessions',
|
|
5
5
|
:registrations => 'spree/user_registrations',
|
|
6
|
-
:passwords => 'spree/user_passwords'
|
|
6
|
+
:passwords => 'spree/user_passwords',
|
|
7
|
+
:confirmations => 'spree/user_confirmations' },
|
|
7
8
|
:skip => [:unlocks, :omniauth_callbacks],
|
|
8
|
-
:path_names => { :sign_out => 'logout' }
|
|
9
|
-
|
|
9
|
+
:path_names => { :sign_out => 'logout' },
|
|
10
|
+
:path_prefix => :user
|
|
10
11
|
|
|
11
|
-
Spree::Core::Engine.routes.prepend do
|
|
12
12
|
resources :users, :only => [:edit, :update]
|
|
13
13
|
|
|
14
|
-
devise_scope :
|
|
14
|
+
devise_scope :spree_user do
|
|
15
15
|
get '/login' => 'user_sessions#new', :as => :login
|
|
16
|
+
post '/login' => 'user_sessions#create', :as => :create_new_session
|
|
17
|
+
get '/logout' => 'user_sessions#destroy', :as => :logout
|
|
16
18
|
get '/signup' => 'user_registrations#new', :as => :signup
|
|
19
|
+
post '/signup' => 'user_registrations#create', :as => :registration
|
|
20
|
+
get '/password/recover' => 'user_passwords#new', :as => :recover_password
|
|
21
|
+
post '/password/recover' => 'user_passwords#create', :as => :reset_password
|
|
22
|
+
get '/password/change' => 'user_passwords#edit', :as => :edit_password
|
|
23
|
+
put '/password/change' => 'user_passwords#update', :as => :update_password
|
|
24
|
+
get '/confirm' => 'user_confirmations#show', :as => :confirmation if Spree::Auth::Config[:confirmable]
|
|
17
25
|
end
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
|
|
28
|
+
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
resource :account, :controller => 'users'
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
namespace :admin do
|
|
33
|
+
devise_for :spree_user,
|
|
34
|
+
:class_name => 'Spree::User',
|
|
35
|
+
:controllers => { :sessions => 'spree/admin/user_sessions',
|
|
36
|
+
:passwords => 'spree/admin/user_passwords' },
|
|
37
|
+
:skip => [:unlocks, :omniauth_callbacks, :registrations],
|
|
38
|
+
:path_names => { :sign_out => 'logout' },
|
|
39
|
+
:path_prefix => :user
|
|
40
|
+
devise_scope :spree_user do
|
|
41
|
+
get '/authorization_failure', :to => 'user_sessions#authorization_failure', :as => :unauthorized
|
|
42
|
+
get '/login' => 'user_sessions#new', :as => :login
|
|
43
|
+
post '/login' => 'user_sessions#create', :as => :create_new_session
|
|
44
|
+
get '/logout' => 'user_sessions#destroy', :as => :logout
|
|
27
45
|
end
|
|
28
|
-
end
|
|
29
46
|
|
|
30
|
-
|
|
47
|
+
end
|
|
31
48
|
end
|
data/db/default/users.rb
CHANGED
|
@@ -55,11 +55,19 @@ def create_admin_user
|
|
|
55
55
|
if Spree::User.find_by_email(email)
|
|
56
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
57
|
else
|
|
58
|
-
admin = Spree::User.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
63
71
|
end
|
|
64
72
|
end
|
|
65
73
|
|
|
@@ -73,4 +81,3 @@ else
|
|
|
73
81
|
puts 'No admin user created.'
|
|
74
82
|
end
|
|
75
83
|
end
|
|
76
|
-
|
|
@@ -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
|
data/{app/controllers → lib/controllers/backend}/spree/admin/admin_resource_controller_decorator.rb
RENAMED
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Spree::Admin::
|
|
1
|
+
Spree::Admin::Orders::CustomerDetailsController.class_eval do
|
|
2
2
|
before_filter :check_authorization
|
|
3
3
|
|
|
4
4
|
private
|
|
@@ -6,8 +6,9 @@ Spree::Admin::OrdersController.class_eval do
|
|
|
6
6
|
load_order
|
|
7
7
|
session[:access_token] ||= params[:token]
|
|
8
8
|
|
|
9
|
-
resource = @order
|
|
9
|
+
resource = @order
|
|
10
10
|
action = params[:action].to_sym
|
|
11
|
+
action = :edit if action == :show # show route renders :edit for this controller
|
|
11
12
|
|
|
12
13
|
authorize! action, resource, session[:access_token]
|
|
13
14
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
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::Store
|
|
7
|
+
|
|
8
|
+
helper 'spree/admin/navigation'
|
|
9
|
+
helper 'spree/admin/tables'
|
|
10
|
+
layout 'spree/layouts/admin'
|
|
11
|
+
|
|
12
|
+
# Overridden due to bug in Devise.
|
|
13
|
+
# respond_with resource, :location => new_session_path(resource_name)
|
|
14
|
+
# is generating bad url /session/new.user
|
|
15
|
+
#
|
|
16
|
+
# overridden to:
|
|
17
|
+
# respond_with resource, :location => spree.login_path
|
|
18
|
+
#
|
|
19
|
+
def create
|
|
20
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
|
21
|
+
|
|
22
|
+
if resource.errors.empty?
|
|
23
|
+
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
|
24
|
+
respond_with resource, :location => spree.admin_login_path
|
|
25
|
+
else
|
|
26
|
+
respond_with_navigational(resource) { render :new }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Devise::PasswordsController allows for blank passwords.
|
|
31
|
+
# Silly Devise::PasswordsController!
|
|
32
|
+
# Fixes spree/spree#2190.
|
|
33
|
+
def update
|
|
34
|
+
if params[:spree_user][:password].blank?
|
|
35
|
+
set_flash_message(:error, :cannot_be_blank)
|
|
36
|
+
render :edit
|
|
37
|
+
else
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
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::Store
|
|
7
|
+
|
|
8
|
+
helper 'spree/admin/navigation'
|
|
9
|
+
helper 'spree/admin/tables'
|
|
10
|
+
layout :resolve_layout
|
|
11
|
+
|
|
12
|
+
def create
|
|
13
|
+
authenticate_spree_user!
|
|
14
|
+
|
|
15
|
+
if spree_user_signed_in?
|
|
16
|
+
respond_to do |format|
|
|
17
|
+
format.html {
|
|
18
|
+
flash[:success] = Spree.t(:logged_in_succesfully)
|
|
19
|
+
redirect_back_or_default(after_sign_in_path_for(spree_current_user))
|
|
20
|
+
}
|
|
21
|
+
format.js {
|
|
22
|
+
user = resource.record
|
|
23
|
+
render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
flash.now[:error] = t('devise.failure.invalid')
|
|
28
|
+
render :new
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def authorization_failure
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
def accurate_title
|
|
37
|
+
Spree.t(:login)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def redirect_back_or_default(default)
|
|
41
|
+
redirect_to(session["spree_user_return_to"] || default)
|
|
42
|
+
session["spree_user_return_to"] = nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def resolve_layout
|
|
46
|
+
case action_name
|
|
47
|
+
when "new", "create"
|
|
48
|
+
"spree/layouts/login"
|
|
49
|
+
else
|
|
50
|
+
"spree/layouts/admin"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
+
require 'spree/core/validators/email'
|
|
1
2
|
Spree::CheckoutController.class_eval do
|
|
2
3
|
before_filter :check_authorization
|
|
3
4
|
before_filter :check_registration, :except => [:registration, :update_registration]
|
|
4
5
|
|
|
5
|
-
helper 'spree/users'
|
|
6
|
-
|
|
7
6
|
def registration
|
|
8
7
|
@user = Spree::User.new
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def update_registration
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
current_order.state = 'address'
|
|
15
|
-
if current_order.update_attributes(params[:order])
|
|
16
|
-
redirect_to checkout_path
|
|
11
|
+
if params[:order][:email] =~ Devise.email_regexp && current_order.update_attribute(:email, params[:order][:email])
|
|
12
|
+
redirect_to spree.checkout_path
|
|
17
13
|
else
|
|
14
|
+
flash[:registration_error] = t(:email_is_invalid, :scope => [:errors, :messages])
|
|
18
15
|
@user = Spree::User.new
|
|
19
16
|
render 'registration'
|
|
20
17
|
end
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
private
|
|
21
|
+
def order_params
|
|
22
|
+
params[:order] ? params.require(:order).permit(:email) : {}
|
|
23
|
+
end
|
|
24
24
|
|
|
25
25
|
def skip_state_validation?
|
|
26
26
|
%w(registration update_registration).include?(params[:action])
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def check_authorization
|
|
30
|
-
authorize!(:edit, current_order,
|
|
30
|
+
authorize!(:edit, current_order, cookies.signed[:guest_token])
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Introduces a registration step whenever the +registration_step+ preference is true.
|
|
@@ -37,11 +37,4 @@ Spree::CheckoutController.class_eval do
|
|
|
37
37
|
store_location
|
|
38
38
|
redirect_to spree.checkout_registration_path
|
|
39
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 order_path(@order) if spree_current_user
|
|
45
|
-
spree.token_order_path(@order, @order.token)
|
|
46
|
-
end
|
|
47
40
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
2
|
+
helper 'spree/base'
|
|
3
|
+
|
|
4
|
+
include Spree::Core::ControllerHelpers::Auth
|
|
5
|
+
include Spree::Core::ControllerHelpers::Common
|
|
6
|
+
include Spree::Core::ControllerHelpers::Order
|
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
|
8
|
+
|
|
9
|
+
protected
|
|
10
|
+
|
|
11
|
+
def after_confirmation_path_for(resource_name, resource)
|
|
12
|
+
signed_in?(resource_name) ? signed_in_root_path(resource) : spree.login_path
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
class Spree::UserPasswordsController < Devise::PasswordsController
|
|
2
|
-
|
|
3
|
-
helper 'spree/users', 'spree/base'
|
|
4
|
-
|
|
5
|
-
if defined?(Spree::Dash)
|
|
6
|
-
helper 'spree/analytics'
|
|
7
|
-
end
|
|
2
|
+
helper 'spree/base'
|
|
8
3
|
|
|
9
4
|
include Spree::Core::ControllerHelpers::Auth
|
|
10
5
|
include Spree::Core::ControllerHelpers::Common
|
|
11
6
|
include Spree::Core::ControllerHelpers::Order
|
|
12
|
-
|
|
13
|
-
ssl_required
|
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
|
14
8
|
|
|
15
9
|
# Overridden due to bug in Devise.
|
|
16
10
|
# respond_with resource, :location => new_session_path(resource_name)
|
|
@@ -34,7 +28,9 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
|
34
28
|
# Silly Devise::PasswordsController!
|
|
35
29
|
# Fixes spree/spree#2190.
|
|
36
30
|
def update
|
|
37
|
-
if params[:
|
|
31
|
+
if params[:spree_user][:password].blank?
|
|
32
|
+
self.resource = resource_class.new
|
|
33
|
+
resource.reset_password_token = params[:spree_user][:reset_password_token]
|
|
38
34
|
set_flash_message(:error, :cannot_be_blank)
|
|
39
35
|
render :edit
|
|
40
36
|
else
|
|
@@ -42,4 +38,9 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
|
42
38
|
end
|
|
43
39
|
end
|
|
44
40
|
|
|
41
|
+
protected
|
|
42
|
+
|
|
43
|
+
def new_session_path(resource_name)
|
|
44
|
+
spree.send("new_#{resource_name}_session_path")
|
|
45
|
+
end
|
|
45
46
|
end
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
2
|
-
|
|
3
|
-
include SslRequirement
|
|
4
|
-
helper 'spree/users', 'spree/base'
|
|
5
|
-
|
|
6
|
-
if defined?(Spree::Dash)
|
|
7
|
-
helper 'spree/analytics'
|
|
8
|
-
end
|
|
2
|
+
helper 'spree/base'
|
|
9
3
|
|
|
10
4
|
include Spree::Core::ControllerHelpers::Auth
|
|
11
5
|
include Spree::Core::ControllerHelpers::Common
|
|
12
6
|
include Spree::Core::ControllerHelpers::Order
|
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
|
13
8
|
|
|
14
|
-
ssl_required
|
|
15
9
|
before_filter :check_permissions, :only => [:edit, :update]
|
|
16
10
|
skip_before_filter :require_no_authentication
|
|
17
11
|
|
|
18
12
|
# GET /resource/sign_up
|
|
19
13
|
def new
|
|
20
14
|
super
|
|
15
|
+
@user = resource
|
|
21
16
|
end
|
|
22
17
|
|
|
23
18
|
# POST /resource/sign_up
|
|
24
19
|
def create
|
|
25
|
-
@user = build_resource(
|
|
20
|
+
@user = build_resource(spree_user_params)
|
|
26
21
|
if resource.save
|
|
27
22
|
set_flash_message(:notice, :signed_up)
|
|
28
|
-
|
|
23
|
+
if current_order
|
|
24
|
+
current_order.associate_user! @user
|
|
25
|
+
end
|
|
26
|
+
sign_in(:spree_user, @user)
|
|
29
27
|
session[:spree_user_signup] = true
|
|
30
|
-
|
|
31
|
-
sign_in_and_redirect(:user, @user)
|
|
28
|
+
respond_with resource, location: after_sign_up_path_for(resource)
|
|
32
29
|
else
|
|
33
30
|
clean_up_passwords(resource)
|
|
34
31
|
render :new
|
|
@@ -60,8 +57,14 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
|
60
57
|
end
|
|
61
58
|
|
|
62
59
|
protected
|
|
63
|
-
def check_permissions
|
|
64
|
-
authorize!(:create, resource)
|
|
65
|
-
end
|
|
66
60
|
|
|
61
|
+
def check_permissions
|
|
62
|
+
authorize!(:create, resource)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def spree_user_params
|
|
68
|
+
params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
|
|
69
|
+
end
|
|
67
70
|
end
|