2009-11-03 09:35:11 -02:00
|
|
|
require 'devise/rails/routes'
|
2010-02-16 14:57:10 +01:00
|
|
|
require 'devise/rails/warden_compat'
|
|
|
|
|
|
|
|
module Devise
|
|
|
|
class Engine < ::Rails::Engine
|
2010-03-30 11:08:16 +02:00
|
|
|
config.devise = Devise
|
|
|
|
|
2010-07-17 09:43:35 +02:00
|
|
|
# Initialize Warden and copy its configurations.
|
2010-05-16 00:38:40 +02:00
|
|
|
config.app_middleware.use Warden::Manager do |config|
|
|
|
|
Devise.warden_config = config
|
2010-04-22 19:59:52 +02:00
|
|
|
end
|
|
|
|
|
2010-05-16 00:38:40 +02:00
|
|
|
# Force routes to be loaded if we are doing any eager load.
|
2011-09-24 03:13:39 +03:00
|
|
|
config.before_eager_load { |app| app.reload_routes! }
|
2010-04-03 13:11:45 +02:00
|
|
|
|
2010-07-13 10:09:55 +02:00
|
|
|
initializer "devise.url_helpers" do
|
2010-07-13 13:35:53 +02:00
|
|
|
Devise.include_helpers(Devise::Controllers)
|
2010-07-13 13:11:04 +02:00
|
|
|
end
|
2011-03-30 14:40:03 +02:00
|
|
|
|
2010-10-14 20:04:02 +02: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-05 02:41:31 +07: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
|
2010-02-16 14:57:10 +01:00
|
|
|
end
|
2010-09-17 20:58:32 -03:00
|
|
|
end
|