omniauth.rb 1001 B

12345678910111213141516171819202122232425262728
  1. begin
  2. require "omniauth"
  3. require "omniauth/version"
  4. rescue LoadError
  5. warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
  6. raise
  7. end
  8. unless OmniAuth::VERSION =~ /^1\./
  9. raise "You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed."
  10. end
  11. # Clean up the default path_prefix. It will be automatically set by Devise.
  12. OmniAuth.config.path_prefix = nil
  13. OmniAuth.config.on_failure = Proc.new do |env|
  14. env['devise.mapping'] = Devise::Mapping.find_by_path!(env['PATH_INFO'], :path)
  15. controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
  16. controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
  17. controller_klass.action(:failure).call(env)
  18. end
  19. module Devise
  20. module OmniAuth
  21. autoload :Config, "devise/omniauth/config"
  22. autoload :UrlHelpers, "devise/omniauth/url_helpers"
  23. end
  24. end