mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: hide restricted profile info from TL0 users to anonymous in 'JS-off' page
This commit is contained in:
parent
65c106325c
commit
07211489f0
4 changed files with 18 additions and 5 deletions
|
@ -30,6 +30,7 @@ class UsersController < ApplicationController
|
|||
user_serializer = UserSerializer.new(@user, scope: guardian, root: 'user')
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@restrict_fields = guardian.restrict_user_fields?(@user)
|
||||
store_preloaded("user_#{@user.username}", MultiJson.dump(user_serializer))
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class UserSerializer < BasicUserSerializer
|
|||
attrs.each do |attr|
|
||||
method_name = "include_#{attr}?"
|
||||
define_method(method_name) do
|
||||
return false if object.trust_level == TrustLevel[0] && scope.anonymous?
|
||||
return false if scope.restrict_user_fields?(object)
|
||||
send(attr).present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
<h2><%= @user.username %></h2>
|
||||
|
||||
<% unless @restrict_fields %>
|
||||
<p><%= raw @user.user_profile.bio_processed %></p>
|
||||
|
||||
<% content_for :head do %>
|
||||
<%= crawlable_meta_data(title: @user.username, description: @user.user_profile.bio_summary, image: @user.small_avatar_url) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title do %><%=t("js.user.profile")%> - <%= @user.username %><% end %>
|
||||
<% content_for :head do %>
|
||||
<% if @restrict_fields %>
|
||||
<%= crawlable_meta_data(title: @user.username, image: @user.small_avatar_url) %>
|
||||
<% else %>
|
||||
<%= crawlable_meta_data(title: @user.username, description: @user.user_profile.bio_summary, image: @user.small_avatar_url) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title do %>
|
||||
<%= t("js.user.profile")%> - <%= @user.username %>
|
||||
<% end %>
|
||||
|
|
|
@ -51,4 +51,8 @@ module UserGuardian
|
|||
is_admin? || (is_staff? && SiteSetting.show_email_on_profile)
|
||||
end
|
||||
|
||||
def restrict_user_fields?(user)
|
||||
user.trust_level == TrustLevel[0] && anonymous?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue