Module: Workarea::Authorization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Impersonation
- Defined in:
- app/controllers/workarea/authorization.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #authorized? ⇒ Boolean
- #check_authorization ⇒ Object
- #require_admin ⇒ Object
- #required_permissions ⇒ Object
- #unauthorized_user ⇒ Object
Instance Method Details
#authorized? ⇒ Boolean
35 36 37 38 39 |
# File 'app/controllers/workarea/authorization.rb', line 35 def current_user.admin? && Array().all? do |area| current_user.try("#{area}_access?") || current_user.try("#{area}?") end end |
#check_authorization ⇒ Object
28 29 30 31 32 33 |
# File 'app/controllers/workarea/authorization.rb', line 28 def return if current_user.blank? || current_user.super_admin? return if .blank? and return false unless end |
#require_admin ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/controllers/workarea/authorization.rb', line 16 def require_admin unless current_user.try(:admin?) flash[:error] = t('workarea.admin.authorization.unauthorized_action') redirect_to storefront.root_path return false end end |
#required_permissions ⇒ Object
24 25 26 |
# File 'app/controllers/workarea/authorization.rb', line 24 def self.class. end |
#unauthorized_user ⇒ Object
41 42 43 44 |
# File 'app/controllers/workarea/authorization.rb', line 41 def flash[:error] = t('workarea.admin.authorization.unauthorized_area') redirect_back fallback_location: root_path end |