login.rb 724 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Login < BaseMutation
  4. include Gql::Mutations::Concerns::HandlesAuthentication
  5. description 'Performs a user login to create a session'
  6. argument :input, Gql::Types::Input::LoginInputType, 'Login input fields.'
  7. field :session, Gql::Types::SessionType, description: 'The current session, if the login was successful.'
  8. field :two_factor_required, Gql::Types::User::LoginTwoFactorMethodsType, description: 'Two factor authentication methods available for the user about to log-in.'
  9. def self.authorize(...)
  10. true
  11. end
  12. def resolve(input:)
  13. authenticate(**input)
  14. end
  15. end
  16. end