Module: Spree::Core::ControllerHelpers::Auth
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseController
- Defined in:
- lib/spree/core/controller_helpers/auth.rb
Instance Method Summary collapse
-
#current_ability ⇒ Object
Needs to be overridden so that we use Spree’s Ability rather than anyone else’s.
-
#store_location(location = nil) ⇒ Object
this will work for devise out of the box for other auth systems you will need to override this method.
- #store_location_session_key ⇒ Object
-
#try_spree_current_user ⇒ Object
proxy method to possible spree_current_user method Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user.
Instance Method Details
#current_ability ⇒ Object
Needs to be overridden so that we use Spree’s Ability rather than anyone else’s.
18 19 20 |
# File 'lib/spree/core/controller_helpers/auth.rb', line 18 def current_ability @current_ability ||= Spree.ability_class.new(try_spree_current_user, { store: current_store }) end |
#store_location(location = nil) ⇒ Object
this will work for devise out of the box for other auth systems you will need to override this method
24 25 26 27 28 29 30 31 |
# File 'lib/spree/core/controller_helpers/auth.rb', line 24 def store_location(location = nil) return if try_spree_current_user location ||= request.fullpath session_key = store_location_session_key session[session_key] = location end |
#store_location_session_key ⇒ Object
33 34 35 |
# File 'lib/spree/core/controller_helpers/auth.rb', line 33 def store_location_session_key "#{Spree.user_class.model_name.singular_route_key.to_sym}_return_to" end |
#try_spree_current_user ⇒ Object
proxy method to possible spree_current_user method Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spree/core/controller_helpers/auth.rb', line 39 def try_spree_current_user # This one will be defined by apps looking to hook into Spree # As per authentication_helpers.rb if respond_to?(:spree_current_user) spree_current_user # This one will be defined by Devise elsif respond_to?(:current_spree_user) current_spree_user end end |