Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37531 - Autocomplete feature for search shows content from forbidden organization for user #10197

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Foreman::Controller::AutoCompleteSearch
def auto_complete_search
begin
model = (controller_name == "hosts") ? Host::Managed : model_of_controller
@items = model.complete_for(params[:search], {:controller => controller_name})
@items = model.complete_for(params[:search], {:controller => controller_name, :enhanced_filter => {:has_column => "organization_id", :filter => {:organization_id => Organization.current.id}}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Katello has its own auto_complete_search definition, this change would need to happen there as well https://github.com/Katello/katello/blob/16440c3907d6b1f64c6edc2a2dedc213085436e0/app/controllers/katello/concerns/filtered_auto_complete_search.rb#L8 . Things like Content > Subscriptions and search for "name = " still offers subscriptions from other organizations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Thorben-D can you please have a look at the last comments?

@items = @items.map do |item|
category = ['and', 'or', 'not', 'has'].include?(item.to_s.sub(/^.*\s+/, '')) ? _('Operators') : ''
part = item.to_s.sub(/^.*\b(and|or)\b/i) { |match| match.sub(/^.*\s+/, '') }
Expand Down
Loading