debian-mirror-gitlab/lib/api/entities/user_safe.rb

20 lines
579 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class UserSafe < Grape::Entity
2021-12-07 22:27:20 +05:30
expose :id, :username
expose :name do |user|
next user.name unless user.project_bot?
2022-04-04 11:22:00 +05:30
next user.name if options[:current_user]&.can?(:read_project, user.projects.first)
2021-12-07 22:27:20 +05:30
# 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:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
2020-03-13 15:44:24 +05:30
end
end
end