Commit 17b99900 authored by Serena Fang's avatar Serena Fang Committed by Douglas Barbosa Alexandre

Apply maintainer suggestions

parent 803ca4b8
......@@ -134,7 +134,7 @@ module Types
end
def redacted_name
object.secure_name(context[:current_user])
object.redacted_name(context[:current_user])
end
end
end
......@@ -47,12 +47,10 @@ module HasUserType
ghost? || (bot? && !project_bot?)
end
def secure_name(viewing_user)
def redacted_name(viewing_user)
return self.name unless self.project_bot?
if self.groups.any?
return self.name if viewing_user&.can?(:read_group, self.groups.first)
end
return self.name if self.groups.any? && viewing_user&.can?(:read_group, self.groups.first)
return self.name if viewing_user&.can?(:read_project, self.projects.first)
......
......@@ -5,7 +5,7 @@ module API
class UserSafe < Grape::Entity
expose :id, :username
expose :name do |user|
user.secure_name(options[:current_user])
user.redacted_name(options[:current_user])
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment