Skip to content

Commit

Permalink
Merge pull request #1013 from sul-dlss/remove-read
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo authored Nov 6, 2023
2 parents dfccc40 + c58b872 commit f6760ac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 117 deletions.
4 changes: 2 additions & 2 deletions app/controllers/file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FileController < ApplicationController
def show
return unless stale?(**cache_headers)

authorize! :read, current_file
authorize! :download, current_file
expires_in 10.minutes
response.headers['Accept-Ranges'] = 'bytes'
response.headers['Content-Length'] = current_file.content_length
Expand Down Expand Up @@ -55,7 +55,7 @@ def cache_headers
{
etag: [current_file.etag, current_user.try(:etag)],
last_modified: current_file.mtime,
public: anonymous_ability.can?(:read, current_file),
public: anonymous_ability.can?(:download, current_file),
template: false
}
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def initialize(user)

models = [StacksFile, StacksImage, StacksMediaStream]

can [:download, :read], models do |f|
can :download, models do |f|
value, rule = f.rights.world_rights_for_file f.file_name

value && (rule.nil? || rule != Dor::RightsAuth::NO_DOWNLOAD_RULE)
Expand All @@ -56,7 +56,7 @@ def initialize(user)
end

if user.stanford?
can [:download, :read], models do |f|
can :download, models do |f|
value, rule = f.rights.stanford_only_rights_for_file f.file_name

value && (rule.nil? || rule != Dor::RightsAuth::NO_DOWNLOAD_RULE)
Expand All @@ -70,7 +70,7 @@ def initialize(user)
end

if user.app_user?
can [:download, :read], models do |f|
can :download, models do |f|
value, rule = f.rights.agent_rights_for_file f.file_name, user.id

value && (rule.nil? || rule != Dor::RightsAuth::NO_DOWNLOAD_RULE)
Expand All @@ -84,7 +84,7 @@ def initialize(user)
end

if user.locations.present?
can [:download, :read], models do |f|
can :download, models do |f|
user.locations.any? do |location|
value, rule = f.rights.location_rights_for_file(f.file_name, location)
value && (rule.nil? || rule != Dor::RightsAuth::NO_DOWNLOAD_RULE)
Expand Down
Loading

0 comments on commit f6760ac

Please sign in to comment.