Sha256: 6eb36e6c3539f1302f14568c47499b4af005ee5a2933f1bb1ff7352ad30f8644

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

##
# Authorization
#
# Basic authorization methods for controllers
module Outpost
  module Controller
    module Authorization
      # Make sure the user can authorize the current resource
      def authorize(resource)
        if !current_user.can_manage?(resource)
          handle_unauthorized(resource)
        end
      end

      # Use this for before_filter. Should be overridden for custom behavor.
      def authorize_resource
        authorize(self.class.model)
      end

      # What to do when a user doesn't have proper permissions
      def handle_unauthorized(resource)
        redirect_to outpost_root_path,
          alert: "You don't have permission to manage " \
                 "#{resource.to_title.pluralize}"
        return false
      end
    end # Authorization
  end # Controller
end # Outpost

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
outpost-cms-0.0.5 lib/outpost/controller/authorization.rb
outpost-cms-0.0.4 lib/outpost/controller/authorization.rb