* Split Settings::Authentication from SiteConfig * Move specs * Sort fields * Update settings usages * Update recaptcha usages * Add data update script * Update spec * Rename SiteConfigParams concern * Fixes, new route, new controller * Controller and service refactoring * More controller and service updates * Spec updates * More spec fixes * Move file * Fix FeedbackMessagesController * Update admin/configs_spec * Fix remaining specs in admin/configs_spec * Fix configs API * Formatting * Clean up old service object * Various fixes * Update DUS * Add model argument to admin_config_label * Fix key name * Fix specs * Add distinct request caches for settings classes * Fix e2e tests * Fix remaining system spec * Make DUS idempotent * Move routes block * Cleanup * Switch to ActiveSupport::CurrentAttributes * Pinned rails-settings-cached * Update e2e test * Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb Co-authored-by: rhymes <rhymes@hey.com> * Add guard to DUS * Temporarily re-add two SiteConfig fields * Fix config show view Co-authored-by: rhymes <rhymes@hey.com>
42 lines
1.3 KiB
Ruby
42 lines
1.3 KiB
Ruby
module DataUpdateScripts
|
|
class MoveAuthenticationSettings
|
|
AUTHENTICATION_SETTINGS = %w[
|
|
allow_email_password_login
|
|
allow_email_password_registration
|
|
apple_client_id
|
|
apple_key_id
|
|
apple_pem
|
|
apple_team_id
|
|
display_email_domain_allow_list_publicly
|
|
facebook_key
|
|
facebook_secret
|
|
github_key
|
|
github_secret
|
|
invite_only_mode
|
|
require_captcha_for_email_password_registration
|
|
twitter_key
|
|
twitter_secret
|
|
].freeze
|
|
|
|
ATTRIBUTES = %i[var value created_at updated_at].freeze
|
|
|
|
def run
|
|
return if Settings::Authentication.any?
|
|
|
|
SiteConfig.transaction do
|
|
config_relation = SiteConfig.where(var: AUTHENTICATION_SETTINGS)
|
|
config_values = config_relation.pluck(*ATTRIBUTES).map do |values|
|
|
ATTRIBUTES.zip(values).to_h
|
|
end
|
|
Settings::Authentication.insert_all(config_values) if config_values.present?
|
|
|
|
# This field has a validation we don't want to skip
|
|
Settings::Authentication.allowed_registration_email_domains =
|
|
SiteConfig.allowed_registration_email_domains
|
|
|
|
# This field got renamed so we migrate it explicitly
|
|
Settings::Authentication.providers = SiteConfig.authentication_providers
|
|
end
|
|
end
|
|
end
|
|
end
|