Commit 7818f732 authored by Andrei Gliga's avatar Andrei Gliga

On Application Settings Page let the user select the enabled OAuth Sign in...

On Application Settings Page let the user select the enabled OAuth Sign in sources instead of the disabled ones
parent 96122034
......@@ -53,14 +53,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
end
disabled_oauth_sign_in_sources = params[:application_setting][:disabled_oauth_sign_in_sources]
if disabled_oauth_sign_in_sources.nil?
params[:application_setting][:disabled_oauth_sign_in_sources] = []
else
disabled_oauth_sign_in_sources.map! do |source|
source.to_str
end
end
enabled_oauth_sign_in_sources = params[:application_setting][:enabled_oauth_sign_in_sources]
params[:application_setting][:disabled_oauth_sign_in_sources] =
AuthHelper.button_based_providers.map(&:to_s) -
(enabled_oauth_sign_in_sources.nil? ? [] : enabled_oauth_sign_in_sources)
params[:application_setting].delete(:enabled_oauth_sign_in_sources)
params.require(:application_setting).permit(
:default_projects_limit,
......@@ -105,6 +104,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:metrics_packet_size,
restricted_visibility_levels: [],
import_sources: [],
enabled_oauth_sign_in_sources: [],
disabled_oauth_sign_in_sources: []
)
end
......
......@@ -63,13 +63,13 @@ module ApplicationSettingsHelper
def oauth_providers_checkboxes(help_block_id)
button_based_providers.map do |source|
checked = current_application_settings.disabled_oauth_sign_in_sources.include?(source.to_s)
disabled = current_application_settings.disabled_oauth_sign_in_sources.include?(source.to_s)
css_class = 'btn'
css_class += ' active' if checked
checkbox_name = 'application_setting[disabled_oauth_sign_in_sources][]'
css_class += ' active' unless disabled
checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
label_tag(checkbox_name, class: css_class) do
check_box_tag(checkbox_name, source, checked,
check_box_tag(checkbox_name, source, !disabled,
autocomplete: 'off',
'aria-describedby' => help_block_id) + Gitlab::OAuth::Provider.label_for(source)
end
......
......@@ -111,7 +111,7 @@
Sign-in enabled
- if omniauth_enabled? && !button_based_providers.empty?
.form-group
= f.label :disable_oauth_signin_sources, 'Disable OAuth Sign-In sources', class: 'control-label col-sm-2'
= f.label :enabled_oauth_sign_in_sources, 'Enabled OAuth Sign-In sources', class: 'control-label col-sm-2'
.col-sm-10
- data_attrs = { toggle: 'buttons' }
.btn-group{ data: data_attrs }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment