A platform for community discussion. Free, open, simple.
FIX: Full names are exposed when name display is disabled (#39838)
Sama7c0f5dd0eea
diff --git a/plugins/discourse-post-voting/app/serializers/post_voting_comment_serializer.rb b/plugins/discourse-post-voting/app/serializers/post_voting_comment_serializer.rbindex 90a5944c065..9dc6bd47236 100644--- a/plugins/discourse-post-voting/app/serializers/post_voting_comment_serializer.rb+++ b/plugins/discourse-post-voting/app/serializers/post_voting_comment_serializer.rb@@ -15,6 +15,10 @@ class PostVotingCommentSerializer < ApplicationSerializerattr_accessor :comments_user_voted+ def include_name?+ SiteSetting.enable_names?+ end+def nameobject.user&.nameenddiff --git a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rbindex e129acddb0c..9c0b3935ba3 100644--- a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb+++ b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb@@ -55,6 +55,17 @@ RSpec.describe PostVoting::CommentsController doexpect(comment["id"]).to eq(comment_3.id)end++ it "does not expose names when names are disabled" do+ SiteSetting.enable_names = false+ comment_2.user.update!(name: "Secret Name")++ get "/post_voting/comments.json", params: { post_id: answer.id, last_comment_id: comment.id }++ expect(response.status).to eq(200)+ expect(response.body).not_to include("Secret Name")+ expect(response.parsed_body["comments"].any? { |comment| comment.key?("name") }).to eq(false)+ endenddescribe "#create" do