application_settings_controller.rb 2.31 KB
Newer Older
1
class Admin::ApplicationSettingsController < Admin::ApplicationController
2
  before_action :set_application_setting
3 4 5 6 7

  def show
  end

  def update
8 9 10 11 12 13
    if @application_setting.update_attributes(application_setting_params)
      redirect_to admin_application_settings_path,
        notice: 'Application settings saved successfully'
    else
      render :show
    end
14 15
  end

16 17 18
  def reset_runners_token
    @application_setting.reset_runners_registration_token!
    flash[:notice] = 'New runners registration token has been generated!'
19
    redirect_to admin_runners_path
20 21
  end

22 23 24
  private

  def set_application_setting
25
    @application_setting = ApplicationSetting.current
26 27 28
  end

  def application_setting_params
29
    restricted_levels = params[:application_setting][:restricted_visibility_levels]
30 31 32
    if restricted_levels.nil?
      params[:application_setting][:restricted_visibility_levels] = []
    else
33 34 35 36 37
      restricted_levels.map! do |level|
        level.to_i
      end
    end

38 39 40 41 42 43 44 45 46
    import_sources = params[:application_setting][:import_sources]
    if import_sources.nil?
      params[:application_setting][:import_sources] = []
    else
      import_sources.map! do |source|
        source.to_str
      end
    end

47 48
    params.require(:application_setting).permit(
      :default_projects_limit,
49
      :default_branch_protection,
50 51
      :signup_enabled,
      :signin_enabled,
52 53
      :require_two_factor_authentication,
      :two_factor_grace_period,
54
      :gravatar_enabled,
55
      :twitter_sharing_enabled,
56
      :sign_in_text,
57
      :help_page_text,
58
      :home_page_url,
59
      :after_sign_out_path,
60
      :max_attachment_size,
61
      :session_expire_delay,
Vinnie Okada's avatar
Vinnie Okada committed
62 63
      :default_project_visibility,
      :default_snippet_visibility,
64
      :restricted_signup_domains_raw,
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
65
      :version_check_enabled,
66
      :admin_notification_email,
67
      :user_oauth_applications,
68
      :shared_runners_enabled,
69
      :max_artifacts_size,
70 71
      :metrics_enabled,
      :metrics_host,
72
      :metrics_port,
73 74 75
      :metrics_pool_size,
      :metrics_timeout,
      :metrics_method_call_threshold,
76
      :metrics_sample_interval,
77 78
      :ip_blocking_enabled,
      :dnsbl_servers_list,
79 80 81
      :recaptcha_enabled,
      :recaptcha_site_key,
      :recaptcha_private_key,
82 83
      :sentry_enabled,
      :sentry_dsn,
84
      restricted_visibility_levels: [],
85
      import_sources: []
86 87 88
    )
  end
end