2020-01-26 13:08:47 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class UserSafe < Grape::Entity
|
2022-09-15 08:13:55 -04:00
|
|
|
include RequestAwareEntity
|
|
|
|
|
2022-11-03 11:11:31 -04:00
|
|
|
expose :id, documentation: { type: 'integer', example: 1 }
|
|
|
|
expose :username, documentation: { type: 'string', example: 'admin' }
|
|
|
|
expose :name, documentation: { type: 'string', example: 'Administrator' } do |user|
|
2022-09-15 08:13:55 -04:00
|
|
|
current_user = request.respond_to?(:current_user) ? request.current_user : options.fetch(:current_user, nil)
|
|
|
|
|
|
|
|
user.redacted_name(current_user)
|
2021-12-06 22:12:22 -05:00
|
|
|
end
|
2020-01-26 13:08:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|