signup_resend.rb 880 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::SignupResend < BaseMutation
  4. include Gql::Concerns::HandlesThrottling
  5. description 'Resend signup verification email.'
  6. argument :email, String, required: true, description: 'The user email'
  7. field :success, Boolean, description: 'This indicates if sending of the token via email was successful.'
  8. def self.authorize(...)
  9. true
  10. end
  11. def ready?(email:)
  12. throttle!(limit: 3, period: 1.minute, by_identifier: email)
  13. end
  14. def resolve(email:)
  15. signup = Service::User::Signup.new(user_data: { email: email }, resend: true)
  16. begin
  17. signup.execute
  18. rescue Service::User::Signup::TokenGenerationError
  19. return error_response({ message: e.message })
  20. end
  21. { success: true }
  22. end
  23. end
  24. end