Class: OpenStax::Accounts::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/openstax/accounts/engine.rb

Constant Summary collapse

SETUP_PROC =
lambda do |env|
  # Useful link for how to pass params through omniauth/doorkeeper:
  #  https://github.com/doorkeeper-gem/doorkeeper/wiki/Passing-parameters-from-a-devise-client-to-doorkeeper-(like-locale)

  # request spec `env` doesn't honor "rack.request.query_hash" shortcut, so we fallback
  # to manually parsing the query string.  Also make sure to use an extra fallback of an
  # empty hash because setting the authorize_params to nil upsets Omniauth.
  query_hash = env["rack.request.query_hash"] ||
               Rack::Utils.parse_nested_query(env["QUERY_STRING"]) ||
               {}
  env['omniauth.strategy'].options.authorize_params = query_hash

  env['omniauth.strategy'].options[:client_options][:site] =
    OpenStax::Accounts.configuration.openstax_accounts_url
end