diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a76c7bb..fe43630 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -242,6 +242,16 @@ # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + ActiveSupport.on_load(:active_record) do + IdentifierScheme.all.each do |scheme| + puts "Registering Omniauth Provider - #{scheme.name}" + config.omniauth scheme.name.downcase.to_sym, + scheme.api_key ||= '', + scheme.api_secret ||= '', + scope: (scheme.params.empty? ? {} : JSON.parse(scheme.params)) + end + end + # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. @@ -263,7 +273,7 @@ # # When using OmniAuth, Devise cannot automatically set OmniAuth path, # so you need to do it manually. For the users scope, it would be: - # config.omniauth_path_prefix = '/my_engine/users/auth' + config.omniauth_path_prefix = '/my_engine/users/auth' # Configure the system to redirect to the home page after a session timeout config.warden do |manager| diff --git a/config/initializers/devise.rb.example b/config/initializers/devise.rb.example index e55980f..64493a3 100644 --- a/config/initializers/devise.rb.example +++ b/config/initializers/devise.rb.example @@ -251,12 +251,11 @@ # Dynamically register the Omniauth Providers ActiveSupport.on_load(:active_record) do IdentifierScheme.all.each do |scheme| - - puts "Registering Omniauth provider: #{scheme.name}" - config.omniauth "#{scheme.name.downcase}".to_sym, - "#{scheme.api_key}", - "#{scheme.api_secret}", - scope: JSON.parse(scheme.params) + puts "Registering Omniauth Provider - #{scheme.name}" + config.omniauth scheme.name.downcase.to_sym, + scheme.api_key ||= '', + scheme.api_secret ||= '', + scope: (scheme.params.empty? ? {} : JSON.parse(scheme.params)) end end