diff options
author | Raffael Schmid <raf@nine.ch> | 2013-12-30 13:26:35 +0100 |
---|---|---|
committer | Raffael Schmid <raf@nine.ch> | 2013-12-30 13:26:35 +0100 |
commit | 568d1c27c5a1b4d6749943240cdba2625eee2b6e (patch) | |
tree | c6ae1157b7e403af0b25d1e261e127a351763438 /config/initializers/devise.rb | |
parent | e2dbe0fad7f04826bde06ae9e8d16ca0bc8a2ce2 (diff) | |
download | gitlab-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.rb | 14 |
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 |