Module: Hydra::Catalog

Extended by:
ActiveSupport::Concern
Includes:
Blacklight::AccessControls::Catalog, Blacklight::Catalog
Included in:
CatalogController
Defined in:
app/controllers/concerns/hydra/catalog.rb

Instance Method Summary collapse

Instance Method Details

#enforce_show_permissions(opts = {}) ⇒ Object

Action-specific enforcement Controller “before” filter for enforcing access controls on show actions

Parameters:

  • opts (Hash) (defaults to: {})

    (optional, not currently used)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/concerns/hydra/catalog.rb', line 9

def enforce_show_permissions(opts={})
  # The "super" method comes from blacklight-access_controls.
  # It will check the read permissions for the record.
  # By default, it will return a Hydra::PermissionsSolrDocument
  # that contains the permissions fields for that record
  # so that you can perform additional permissions checks.
  permissions_doc = super

  if permissions_doc.under_embargo? && !can?(:edit, permissions_doc)
    raise Hydra::AccessDenied.new("This item is under embargo.  You do not have sufficient access privileges to read this document.", :edit, params[:id])
  end

  permissions_doc
end