run_auto_wizard.rb 1013 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class System::Setup::RunAutoWizard < BaseMutation
  4. include Gql::Mutations::Concerns::HandlesAuthentication
  5. description 'Executes the auto wizard for automated system set-up.'
  6. argument :token, String, required: false, description: 'Auto wizard access token'
  7. field :session, Gql::Types::SessionType, description: 'The current session, if the auto wizard was successfully executed.'
  8. def self.authorize(...)
  9. true
  10. end
  11. def resolve(token: nil)
  12. user = Service::System::RunAutoWizard.new.execute(token:)
  13. create_session(user, false, 'password')
  14. authenticate_result.tap do
  15. Setting.set('system_init_done', true)
  16. end
  17. rescue Service::System::RunAutoWizard::AutoWizardNotEnabledError, Service::System::RunAutoWizard::AutoWizardExecutionError
  18. error_response({ message: __('An unexpected error occurred during system setup.') })
  19. end
  20. end
  21. end