Module: Cms::Authentication::Controller::ClassMethods

Defined in:
lib/cms/authentication/controller.rb

Instance Method Summary collapse

Instance Method Details

#check_permissions(*perms) ⇒ Object

Determines if the current user has at least one of the following permissions. Sets up a before_action that enforces permissions.

Example: class MyCustomController < Cms::ApplicationController

check_permissions :publish_content, :except => [:index]

end

Parameters:

  • perms (Symbol, Array<Symbol>)

    One or more permissions.

Raises:



44
45
46
47
48
49
# File 'lib/cms/authentication/controller.rb', line 44

def check_permissions(*perms)
  opts = Hash === perms.last ? perms.pop : {}
  before_filter(opts) do |controller|
    raise Cms::Errors::AccessDenied unless controller.send(:current_user).able_to?(*perms)
  end
end