Skip to content

Commit

Permalink
Use correct policy class is search controller
Browse files Browse the repository at this point in the history
The authorization_policy on the resource should be used when set.
  • Loading branch information
martinemde committed Jun 1, 2024
1 parent 748c09d commit 868fb02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/avo/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def search_resources(resources)
resources
.map do |resource|
# Apply authorization
next unless @authorization.set_record(resource.model_class).authorize_action(:search, raise_exception: false)
next unless @authorization.set_record(resource.model_class).authorize_action(
:search,
policy_class: resource.authorization_policy,
raise_exception: false
)
# Filter out the models without a search_query
next if resource.search_query.nil?

Expand Down

0 comments on commit 868fb02

Please sign in to comment.