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

Remove unneeded changes

Remove uneeded changes
parent 14b4120f
...@@ -40,7 +40,9 @@ class MemberEntity < Grape::Entity ...@@ -40,7 +40,9 @@ class MemberEntity < Grape::Entity
expose :valid_level_roles, as: :valid_roles expose :valid_level_roles, as: :valid_roles
expose :user, if: -> (member) { member.user.present? }, using: MemberUserEntity expose :user, if: -> (member) { member.user.present? } do |member, options|
MemberUserEntity.represent(member.user, options)
end
expose :state expose :state
......
...@@ -10,6 +10,6 @@ module RequestAwareEntity ...@@ -10,6 +10,6 @@ module RequestAwareEntity
end end
def request def request
options.fetch(:request, nil) options.fetch(:request)
end end
end end
...@@ -3,19 +3,15 @@ ...@@ -3,19 +3,15 @@
module API module API
module Entities module Entities
class UserSafe < Grape::Entity class UserSafe < Grape::Entity
include RequestAwareEntity
expose :id, :username expose :id, :username
expose :name do |user| expose :name do |user|
next user.name unless user.project_bot? next user.name unless user.project_bot?
current_user = request.respond_to?(:current_user) ? request.current_user : options.fetch(:current_user, nil)
if user.groups if user.groups
next user.name if current_user&.can?(:read_group, user.groups.first) next user.name if options[:current_user]&.can?(:read_group, user.groups.first)
end end
next user.name if current_user&.can?(:read_project, user.projects.first) next user.name if options[:current_user]&.can?(:read_project, user.projects.first)
# If the requester does not have permission to read the project bot name, # If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue: # the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
......
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