signup_verify.rb 841 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::SignupVerify < BaseMutation
  4. include Gql::Mutations::Concerns::HandlesAuthentication
  5. description 'Verify a signed up user.'
  6. argument :token, String, required: true, description: 'Verification token'
  7. field :session, Gql::Types::SessionType, description: 'The current session, if the verification was successful.'
  8. def self.authorize(...)
  9. true
  10. end
  11. def resolve(token:)
  12. verify = Service::User::SignupVerify.new(token: token)
  13. begin
  14. user = verify.execute
  15. rescue Service::User::SignupVerify::InvalidTokenError => e
  16. return error_response({ message: e.message })
  17. end
  18. create_session(user, false, 'password')
  19. authenticate_result
  20. end
  21. end
  22. end