2009-11-03 06:35:11 -05:00
|
|
|
require 'devise/rails/routes'
|
2010-02-16 08:57:10 -05:00
|
|
|
require 'devise/rails/warden_compat'
|
|
|
|
|
|
|
|
module Devise
|
|
|
|
class Engine < ::Rails::Engine
|
2010-03-30 05:08:16 -04:00
|
|
|
config.devise = Devise
|
|
|
|
|
2010-07-17 03:43:35 -04:00
|
|
|
# Initialize Warden and copy its configurations.
|
2010-05-15 18:38:40 -04:00
|
|
|
config.app_middleware.use Warden::Manager do |config|
|
|
|
|
Devise.warden_config = config
|
2010-04-22 13:59:52 -04:00
|
|
|
end
|
|
|
|
|
2010-05-15 18:38:40 -04:00
|
|
|
# Force routes to be loaded if we are doing any eager load.
|
2011-09-22 14:56:18 -04:00
|
|
|
config.before_eager_load { |app| app.reload_routes! unless ENV["RAILS_ASSETS_PRECOMPILE"] }
|
2010-04-03 07:11:45 -04:00
|
|
|
|
2010-07-13 04:09:55 -04:00
|
|
|
initializer "devise.url_helpers" do
|
2010-07-13 07:35:53 -04:00
|
|
|
Devise.include_helpers(Devise::Controllers)
|
2010-07-13 07:11:04 -04:00
|
|
|
end
|
|
|
|
|
2011-03-30 08:40:03 -04:00
|
|
|
initializer "devise.auth_keys" do
|
|
|
|
if Devise.authentication_keys.size > 1
|
|
|
|
puts "[DEVISE] You are configuring Devise to use more than one authentication key. " \
|
|
|
|
"In previous versions, we automatically added #{Devise.authentication_keys[1..-1].inspect} " \
|
|
|
|
"as scope to your e-mail validation, but this was changed now. If you were relying in such " \
|
|
|
|
"behavior, you should remove :validatable from your models and add the validations manually. " \
|
|
|
|
"To get rid of this warning, you can comment config.authentication_keys in your initializer " \
|
|
|
|
"and pass the current values as key to the devise call in your model."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-10-14 14:04:02 -04: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 15:41:31 -04: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 08:57:10 -05:00
|
|
|
end
|
2010-09-17 19:58:32 -04:00
|
|
|
end
|