configuration.rb 838 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class User::Current::TwoFactor::Configuration < BaseQuery
  4. description 'Fetch list of configured two factor authentication methods and .'
  5. type Gql::Types::User::ConfigurationTwoFactorType, null: false
  6. def self.authorize(_obj, ctx)
  7. ctx.current_user.permissions?('user_preferences.two_factor_authentication')
  8. end
  9. def resolve(...)
  10. enabled_authentication_methods = context.current_user.two_factor_enabled_authentication_methods
  11. {
  12. enabled_authentication_methods: enabled_authentication_methods.each { |item| item[:authentication_method] = item.delete(:method) },
  13. recovery_codes_exist: context.current_user.auth_two_factor.user_recovery_codes_exists?
  14. }
  15. end
  16. end
  17. end