mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
SECURITY: Don't expose user post counts to users who can't see the topic (#19728)
Co-authored-by: Penar Musaraj <pmusaraj@gmail.com> Co-authored-by: Daniel Waterworth <me@danielwaterworth.com> Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:

committed by
GitHub

parent
c0e2d7bada
commit
cbcf8a064b
@ -72,7 +72,7 @@ class UsersController < ApplicationController
|
||||
user_serializer = serializer_class.new(@user, scope: guardian, root: 'user')
|
||||
|
||||
topic_id = params[:include_post_count_for].to_i
|
||||
if topic_id != 0
|
||||
if topic_id != 0 && guardian.can_see?(Topic.find_by_id(topic_id))
|
||||
user_serializer.topic_post_count = { topic_id => Post.secured(guardian).where(topic_id: topic_id, user_id: @user.id).count }
|
||||
end
|
||||
else
|
||||
|
Reference in New Issue
Block a user