Class: Refinery::Authentication::Devise::AuthorisationAdapter
- Inherits:
-
Core::AuthorisationAdapter
- Object
- Core::AuthorisationAdapter
- Refinery::Authentication::Devise::AuthorisationAdapter
- Defined in:
- lib/refinery/authentication/devise/authorisation_adapter.rb
Instance Method Summary collapse
- #allow?(operation, resource) ⇒ Boolean
-
#current_user ⇒ Object
If no user exists, we use a NilUser (non-admin).
-
#current_user=(set_to_this_user) ⇒ Object
This method has been added, it does not exist in the superclass.
Instance Method Details
#allow?(operation, resource) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/refinery/authentication/devise/authorisation_adapter.rb', line 18 def allow?(operation, resource) case when resource == :site_bar current_user.has_role?(:refinery) when operation == :plugin current_user.active_plugins.names.include?(resource) when operation == :controller current_user.active_plugins.any? do |plugin| Regexp.new(plugin.) === resource end else false end end |
#current_user ⇒ Object
If no user exists, we use a NilUser (non-admin).
9 10 11 |
# File 'lib/refinery/authentication/devise/authorisation_adapter.rb', line 9 def current_user @current_user ||= Refinery::Authentication::Devise::NilUser.new end |
#current_user=(set_to_this_user) ⇒ Object
This method has been added, it does not exist in the superclass.
14 15 16 |
# File 'lib/refinery/authentication/devise/authorisation_adapter.rb', line 14 def current_user=(set_to_this_user) @current_user = set_to_this_user end |