2009-11-03 11:35:11 +00:00
|
|
|
require 'devise/rails/routes'
|
2010-02-16 13:57:10 +00:00
|
|
|
require 'devise/rails/warden_compat'
|
|
|
|
|
|
|
|
module Devise
|
|
|
|
class Engine < ::Rails::Engine
|
2010-03-30 09:08:16 +00:00
|
|
|
config.devise = Devise
|
|
|
|
|
2010-07-17 07:43:35 +00:00
|
|
|
# Initialize Warden and copy its configurations.
|
2010-05-15 22:38:40 +00:00
|
|
|
config.app_middleware.use Warden::Manager do |config|
|
|
|
|
Devise.warden_config = config
|
2010-04-22 17:59:52 +00:00
|
|
|
end
|
|
|
|
|
2010-05-15 22:38:40 +00:00
|
|
|
# Force routes to be loaded if we are doing any eager load.
|
2011-09-24 00:13:39 +00:00
|
|
|
config.before_eager_load { |app| app.reload_routes! }
|
2010-04-03 11:11:45 +00:00
|
|
|
|
2010-07-13 08:09:55 +00:00
|
|
|
initializer "devise.url_helpers" do
|
2010-07-13 11:35:53 +00:00
|
|
|
Devise.include_helpers(Devise::Controllers)
|
2010-07-13 11:11:04 +00:00
|
|
|
end
|
2011-03-30 12:40:03 +00:00
|
|
|
|
2010-10-14 18:04:02 +00:00
|
|
|
initializer "devise.omniauth" do |app|
|
|
|
|
Devise.omniauth_configs.each do |provider, config|
|
|
|
|
app.middleware.use config.strategy_class, *config.args do |strategy|
|
|
|
|
config.strategy = strategy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if Devise.omniauth_configs.any?
|
|
|
|
Devise.include_helpers(Devise::OmniAuth)
|
|
|
|
end
|
|
|
|
end
|
2011-08-04 19:41:31 +00:00
|
|
|
|
|
|
|
initializer "devise.mongoid_version_warning" do
|
|
|
|
if defined?(Mongoid)
|
|
|
|
require 'mongoid/version'
|
|
|
|
if Mongoid::VERSION.to_f < 2.1
|
|
|
|
puts "\n[DEVISE] Please note that Mongoid versions prior to 2.1 handle dirty model " \
|
|
|
|
"object attributes in such a way that the Devise `validatable` module will not apply " \
|
|
|
|
"its usual uniqueness and format validations for the email field. It is recommended " \
|
|
|
|
"that you upgrade to Mongoid 2.1+ for this and other fixes, but if for some reason you " \
|
|
|
|
"are unable to do so, you should add these validations manually.\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-12-04 22:58:19 +00:00
|
|
|
|
2012-01-03 19:32:51 +00:00
|
|
|
initializer "devise.fix_routes_proxy_missing_respond_to_bug" do
|
2012-05-06 11:13:53 +00:00
|
|
|
# We can get rid of this once we support only Rails > 3.2
|
2012-01-03 19:32:51 +00:00
|
|
|
ActionDispatch::Routing::RoutesProxy.class_eval do
|
|
|
|
def respond_to?(method, include_private = false)
|
|
|
|
super || routes.url_helpers.respond_to?(method)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-02-16 13:57:10 +00:00
|
|
|
end
|
2010-09-17 23:58:32 +00:00
|
|
|
end
|