Module: Newshound::Authorization
- Defined in:
- lib/newshound/authorization.rb
Class Method Summary collapse
-
.authorized?(controller) ⇒ Boolean
Check if the current user/controller is authorized to view Newshound data.
Class Method Details
.authorized?(controller) ⇒ Boolean
Check if the current user/controller is authorized to view Newshound data
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/newshound/authorization.rb', line 7 def (controller) return false unless Newshound.configuration.enabled # Use custom authorization block if provided if Newshound.configuration. return Newshound.configuration..call(controller) end # Default authorization: check if current_user has an authorized role user = current_user_from(controller) return false unless user user_role = user_role_from(user) return false unless user_role Newshound.configuration..include?(user_role.to_sym) end |