Sha256: 90332d051432da27fc0f14483db937b40635f1f99cd116671f43813507174915

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module AccessControls
    # This is behavior for the catalog controller.
    module Catalog
      extend ActiveSupport::Concern

      # 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

      # This will work for BL 6, but will need to move to SearchService in BL 7
      def search_builder
        Blacklight::AccessControls::SearchBuilder.new(self, ability: current_ability)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-access_controls-6.0.1 lib/blacklight/access_controls/catalog.rb
blacklight-access_controls-6.0.0 lib/blacklight/access_controls/catalog.rb
blacklight-access_controls-0.7.0 lib/blacklight/access_controls/catalog.rb