summaryrefslogtreecommitdiff
path: root/config/initializers/devise.rb
diff options
context:
space:
mode:
authorRaffael Schmid <raf@nine.ch>2013-12-30 13:26:35 +0100
committerRaffael Schmid <raf@nine.ch>2013-12-30 13:26:35 +0100
commit568d1c27c5a1b4d6749943240cdba2625eee2b6e (patch)
treec6ae1157b7e403af0b25d1e261e127a351763438 /config/initializers/devise.rb
parente2dbe0fad7f04826bde06ae9e8d16ca0bc8a2ce2 (diff)
downloadgitlab-ce-568d1c27c5a1b4d6749943240cdba2625eee2b6e.tar.gz
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.
Diffstat (limited to 'config/initializers/devise.rb')
-rw-r--r--config/initializers/devise.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 25390978cf6..e12f07fa6fc 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -227,15 +227,21 @@ Devise.setup do |config|
end
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']
when Array
# 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
# A Hash from the configuration will be passed as is.
- config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args']
- else
- config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret']
+ provider_arguments << provider['args']
end
+
+ config.omniauth provider['name'].to_sym, *provider_arguments
end
end