20211123144240_issue3622_add_callback_url.rb 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue3622AddCallbackUrl < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. configs = {
  6. auth_twitter_credentials: 'auth_twitter',
  7. auth_facebook_credentials: 'auth_facebook',
  8. auth_google_oauth2_credentials: 'auth_google_oauth2',
  9. auth_linkedin_credentials: 'auth_linkedin',
  10. auth_github_credentials: 'auth_github',
  11. auth_gitlab_credentials: 'auth_gitlab',
  12. auth_microsoft_office365_credentials: 'auth_microsoft_office365',
  13. auth_weibo_credentials: 'auth_weibo',
  14. auth_saml_credentials: 'auth_saml',
  15. }
  16. configs.each do |key, value|
  17. config = Setting.find_by(name: key)
  18. config.options['form'] << {
  19. 'display' => 'Your callback URL',
  20. 'null' => true,
  21. 'name' => 'callback_url',
  22. 'tag' => 'auth_provider',
  23. 'provider' => value
  24. }
  25. config.save!
  26. end
  27. end
  28. end