signup_verify.rb 615 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::User::SignupVerify < Service::Base
  3. attr_reader :token, :current_user
  4. def initialize(token:, current_user: nil)
  5. super()
  6. @token = token
  7. @current_user = current_user
  8. end
  9. def execute
  10. Service::CheckFeatureEnabled.new(name: 'user_create_account').execute
  11. user = ::User.signup_verify_via_token(token, current_user)
  12. raise InvalidTokenError if !user
  13. user
  14. end
  15. class InvalidTokenError < StandardError
  16. def initialize
  17. super(__('The provided token is invalid.'))
  18. end
  19. end
  20. end