refactor omniauth configuration method

This refactoring allows a user to use omniauth providers which do not
use ```app_id``` and ```app_secret``` without needing to change the
devise configuration.
This commit is contained in:
Raffael Schmid 2013-12-30 13:26:35 +01:00
parent e2dbe0fad7
commit 568d1c27c5

View file

@ -227,15 +227,21 @@ Devise.setup do |config|
end end
Gitlab.config.omniauth.providers.each do |provider| Gitlab.config.omniauth.providers.each do |provider|
provider_arguments = []
%w[app_id app_secret].each do |argument|
provider_arguments << provider[argument] if provider[argument]
end
case provider['args'] case provider['args']
when Array when Array
# An Array from the configuration will be expanded. # An Array from the configuration will be expanded.
config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], *provider['args'] provider_arguments.concat provider['args']
when Hash when Hash
# A Hash from the configuration will be passed as is. # A Hash from the configuration will be passed as is.
config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args'] provider_arguments << provider['args']
else
config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret']
end end
config.omniauth provider['name'].to_sym, *provider_arguments
end end
end end