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

Fix bot token name in issues

Changelog: fixed
parent 35f1dd93
...@@ -40,9 +40,7 @@ class MemberEntity < Grape::Entity ...@@ -40,9 +40,7 @@ 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? } do |member, options| expose :user, if: -> (member) { member.user.present? }, using: MemberUserEntity
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) options.fetch(:request, nil)
end end
end end
...@@ -3,11 +3,15 @@ ...@@ -3,11 +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?
next user.name if options[:current_user]&.can?(:read_project, user.projects.first) current_user = request.respond_to?(:current_user) ? request.current_user : options.fetch(:current_user, nil)
next user.name if 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