module Outpost::Controller::Authorization
Public Instance Methods
authorize(resource)
click to toggle source
Make sure the user can authorize the current resource
# File lib/outpost/controller/authorization.rb, line 9 def authorize(resource) if !current_user.can_manage?(resource) handle_unauthorized(resource) end end
authorize_resource()
click to toggle source
Use this for before_filter. Should be overridden for custom behavor.
# File lib/outpost/controller/authorization.rb, line 16 def authorize_resource authorize(self.class.model) end
handle_unauthorized(resource)
click to toggle source
What to do when a user doesn't have proper permissions
# File lib/outpost/controller/authorization.rb, line 21 def handle_unauthorized(resource) redirect_to outpost.root_path, alert: "You don't have permission to manage " \ "#{resource.to_title.pluralize}" return false end