Skip to content

Commit

Permalink
πŸ› Fix thumbnails not showing for logged out users
Browse files Browse the repository at this point in the history
This commit overrides an ability mixin to check for either the slugs or
id so when it's used downstream, we can ensure that the thumbnails are
displaying correctly due to the permissions being set correctly.
  • Loading branch information
Kirk Wang committed Sep 14, 2024
1 parent 3029177 commit 72984ee
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/models/concerns/hyrax/ability/resource_ability_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# OVERRIDE Hyrax v5.0.1 to add support for slugs

module Hyrax
module Ability
module ResourceAbilityDecorator
def resource_abilities
if admin?
can [:manage], ::Hyrax::Resource
else
can [:edit, :update, :destroy], ::Hyrax::Resource do |res|
test_edit(res.to_param) # #to_param checks for slug or id
end
can :read, ::Hyrax::Resource do |res|
test_read(res.to_param) # #to_param checks for slug or id
end
end
end
end
end
end

Hyrax::Ability::ResourceAbility.prepend(Hyrax::Ability::ResourceAbilityDecorator)

0 comments on commit 72984ee

Please sign in to comment.