Commit 568d1c27c5a1b4d6749943240cdba2625eee2b6e
1 parent
e2dbe0fa
Exists in
spb-stable
and in
3 other branches
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.
Showing
1 changed file
with
10 additions
and
4 deletions
Show diff stats
config/initializers/devise.rb
@@ -227,15 +227,21 @@ Devise.setup do |config| | @@ -227,15 +227,21 @@ Devise.setup do |config| | ||
227 | end | 227 | end |
228 | 228 | ||
229 | Gitlab.config.omniauth.providers.each do |provider| | 229 | Gitlab.config.omniauth.providers.each do |provider| |
230 | + provider_arguments = [] | ||
231 | + | ||
232 | + %w[app_id app_secret].each do |argument| | ||
233 | + provider_arguments << provider[argument] if provider[argument] | ||
234 | + end | ||
235 | + | ||
230 | case provider['args'] | 236 | case provider['args'] |
231 | when Array | 237 | when Array |
232 | # An Array from the configuration will be expanded. | 238 | # An Array from the configuration will be expanded. |
233 | - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], *provider['args'] | 239 | + provider_arguments.concat provider['args'] |
234 | when Hash | 240 | when Hash |
235 | # A Hash from the configuration will be passed as is. | 241 | # A Hash from the configuration will be passed as is. |
236 | - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args'] | ||
237 | - else | ||
238 | - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'] | 242 | + provider_arguments << provider['args'] |
239 | end | 243 | end |
244 | + | ||
245 | + config.omniauth provider['name'].to_sym, *provider_arguments | ||
240 | end | 246 | end |
241 | end | 247 | end |