Sha256: 20750c334ed184966fe22c730eb08e21cc4cd63849aa55a2ec907596a0053deb

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

# This is behavior for the catalog controller.

module Blacklight
  module AccessControls
    module Catalog
      extend ActiveSupport::Concern

      # Override blacklight to produce a search_builder that has
      # the current ability in context
      def search_builder processor_chain = search_params_logic
        super(true).tap { |builder| builder.current_ability = current_ability }
      end 

      # Controller "before" filter for enforcing access controls
      # on show actions.
      # @param [Hash] opts (optional, not currently used)
      def enforce_show_permissions(opts={})
        permissions = current_ability.permissions_doc(params[:id])
        unless can? :read, permissions
          raise Blacklight::AccessControls::AccessDenied.new("You do not have sufficient access privileges to read this document, which has been marked private.", :read, params[:id])
        end
        permissions
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blacklight-access_controls-0.2.0 lib/blacklight/access_controls/catalog.rb
blacklight-access_controls-0.1.0 lib/blacklight/access_controls/catalog.rb