internal_field.rb 477 B

12345678910111213141516
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Fields
  3. # Represents internal fields like 'note' which can only be accessed with admin/agent permission.
  4. class InternalField < BaseField
  5. def resolve(object, args, context)
  6. authorize_field(context) ? super(object, args, context) : nil
  7. end
  8. private
  9. def authorize_field(context)
  10. context.current_user.permissions? ['ticket.agent', 'admin.*']
  11. end
  12. end
  13. end