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 ...@@ -53,14 +53,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
end end
disabled_oauth_sign_in_sources = params[:application_setting][:disabled_oauth_sign_in_sources] enabled_oauth_sign_in_sources = params[:application_setting][:enabled_oauth_sign_in_sources]
if disabled_oauth_sign_in_sources.nil?
params[:application_setting][:disabled_oauth_sign_in_sources] = [] params[:application_setting][:disabled_oauth_sign_in_sources] =
else AuthHelper.button_based_providers.map(&:to_s) -
disabled_oauth_sign_in_sources.map! do |source| (enabled_oauth_sign_in_sources.nil? ? [] : enabled_oauth_sign_in_sources)
source.to_str
end params[:application_setting].delete(:enabled_oauth_sign_in_sources)
end
params.require(:application_setting).permit( params.require(:application_setting).permit(
:default_projects_limit, :default_projects_limit,
...@@ -105,6 +104,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -105,6 +104,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:metrics_packet_size, :metrics_packet_size,
restricted_visibility_levels: [], restricted_visibility_levels: [],
import_sources: [], import_sources: [],
enabled_oauth_sign_in_sources: [],
disabled_oauth_sign_in_sources: [] disabled_oauth_sign_in_sources: []
) )
end end
......
...@@ -63,13 +63,13 @@ module ApplicationSettingsHelper ...@@ -63,13 +63,13 @@ module ApplicationSettingsHelper
def oauth_providers_checkboxes(help_block_id) def oauth_providers_checkboxes(help_block_id)
button_based_providers.map do |source| 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 = 'btn'
css_class += ' active' if checked css_class += ' active' unless disabled
checkbox_name = 'application_setting[disabled_oauth_sign_in_sources][]' checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
label_tag(checkbox_name, class: css_class) do label_tag(checkbox_name, class: css_class) do
check_box_tag(checkbox_name, source, checked, check_box_tag(checkbox_name, source, !disabled,
autocomplete: 'off', autocomplete: 'off',
'aria-describedby' => help_block_id) + Gitlab::OAuth::Provider.label_for(source) 'aria-describedby' => help_block_id) + Gitlab::OAuth::Provider.label_for(source)
end end
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
Sign-in enabled Sign-in enabled
- if omniauth_enabled? && !button_based_providers.empty? - if omniauth_enabled? && !button_based_providers.empty?
.form-group .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 .col-sm-10
- data_attrs = { toggle: 'buttons' } - data_attrs = { toggle: 'buttons' }
.btn-group{ data: data_attrs } .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