Skip to content

Commit

Permalink
Do not search unreadable messageboard
Browse files Browse the repository at this point in the history
Searching all messageboards would previously search in
messageboards the user does not have read access to.

This commit fixes the issue.
  • Loading branch information
glebm committed May 16, 2016
1 parent 56e86f5 commit 77293c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/thredded/topics_controller.rb
Expand Up @@ -37,9 +37,14 @@ def show

def search
@query = params[:q].to_s
topics_scope = if messageboard_or_nil
messageboard.topics
else
Topic.where(messageboard_id: thredded_current_user.thredded_can_read_messageboards.pluck(:id))
end
@topics = Thredded::TopicsPageView.new(
thredded_current_user,
(messageboard_or_nil ? messageboard.topics : Topic)
topics_scope
.search_query(@query)
.order_recently_updated_first
.includes(:categories, :last_user, :user)
Expand Down

0 comments on commit 77293c8

Please sign in to comment.