2017-12-21 12:36:29 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2010-10-14 14:04:02 -04:00
|
|
|
begin
|
2011-10-14 16:33:56 -04:00
|
|
|
require "omniauth"
|
2011-11-20 14:42:02 -05:00
|
|
|
require "omniauth/version"
|
2012-05-15 16:22:52 -04:00
|
|
|
rescue LoadError
|
2011-10-14 16:33:56 -04:00
|
|
|
warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
|
2010-10-14 14:04:02 -04:00
|
|
|
raise
|
|
|
|
end
|
|
|
|
|
2021-01-07 07:21:14 -05:00
|
|
|
if Gem::Version.new(OmniAuth::VERSION) < Gem::Version.new('1.0.0')
|
|
|
|
raise "You are using an old OmniAuth version, please ensure you have 1.0.0 version or later installed."
|
2010-10-14 14:04:02 -04:00
|
|
|
end
|
|
|
|
|
2010-10-14 15:16:20 -04:00
|
|
|
# Clean up the default path_prefix. It will be automatically set by Devise.
|
|
|
|
OmniAuth.config.path_prefix = nil
|
|
|
|
|
2011-02-24 14:50:22 -05:00
|
|
|
OmniAuth.config.on_failure = Proc.new do |env|
|
2010-10-29 16:43:13 -04:00
|
|
|
env['devise.mapping'] = Devise::Mapping.find_by_path!(env['PATH_INFO'], :path)
|
2011-04-16 07:30:15 -04:00
|
|
|
controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
|
|
|
|
controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
|
|
|
|
controller_klass.action(:failure).call(env)
|
2010-10-14 19:15:17 -04:00
|
|
|
end
|
|
|
|
|
2010-10-14 14:04:02 -04:00
|
|
|
module Devise
|
|
|
|
module OmniAuth
|
|
|
|
autoload :Config, "devise/omniauth/config"
|
|
|
|
autoload :UrlHelpers, "devise/omniauth/url_helpers"
|
|
|
|
end
|
2010-11-03 19:16:55 -04:00
|
|
|
end
|