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'
|
|
|
|
|
2010-05-15 18:38:40 -04:00
|
|
|
# Include UrlHelpers in ActionController and ActionView as soon as they are loaded.
|
|
|
|
ActiveSupport.on_load(:action_controller) { include Devise::Controllers::UrlHelpers }
|
|
|
|
ActiveSupport.on_load(:action_view) { include Devise::Controllers::UrlHelpers }
|
|
|
|
|
2010-02-16 08:57:10 -05:00
|
|
|
module Devise
|
|
|
|
class Engine < ::Rails::Engine
|
2010-03-30 05:08:16 -04:00
|
|
|
config.devise = Devise
|
|
|
|
|
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.
|
|
|
|
config.before_eager_load { |app| app.reload_routes! }
|
2010-04-03 07:11:45 -04:00
|
|
|
|
2010-06-12 08:46:55 -04:00
|
|
|
config.after_initialize do
|
|
|
|
Devise.encryptor ||= begin
|
|
|
|
warn "[WARNING] config.encryptor is not set in your config/initializers/devise.rb. " \
|
|
|
|
"Devise will then set it to :bcrypt. If you were using the previous default " \
|
2010-07-06 08:58:40 -04:00
|
|
|
"encryptor, please add config.encryptor = :sha1 to your configuration file." if Devise.mailer_sender
|
2010-06-12 08:46:55 -04:00
|
|
|
:bcrypt
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
unless Rails.env.production?
|
|
|
|
config.after_initialize do
|
|
|
|
actions = [:confirmation_instructions, :reset_password_instructions, :unlock_instructions]
|
2010-06-12 14:29:43 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
translations = begin
|
|
|
|
I18n.t("devise.mailer", :raise => true).map { |k, v| k if v.is_a?(String) }.compact
|
|
|
|
rescue Exception => e # Do not care if something fails
|
|
|
|
[]
|
|
|
|
end
|
2010-06-12 14:29:43 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
keys = actions & translations
|
2010-06-12 14:29:43 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
keys.each do |key|
|
|
|
|
ActiveSupport::Deprecation.warn "The I18n message 'devise.mailer.#{key}' is deprecated. " \
|
|
|
|
"Please use 'devise.mailer.#{key}.subject' instead."
|
|
|
|
end
|
2010-06-12 14:29:43 -04:00
|
|
|
end
|
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
config.after_initialize do
|
|
|
|
flash = [:unauthenticated, :unconfirmed, :invalid, :invalid_token, :timeout, :inactive, :locked]
|
2010-04-03 07:11:45 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
translations = begin
|
|
|
|
I18n.t("devise.sessions", :raise => true).keys
|
|
|
|
rescue Exception => e # Do not care if something fails
|
|
|
|
[]
|
|
|
|
end
|
2010-05-15 18:38:40 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
keys = flash & translations
|
2010-04-03 07:11:45 -04:00
|
|
|
|
2010-06-21 08:07:58 -04:00
|
|
|
if keys.any?
|
|
|
|
ActiveSupport::Deprecation.warn "The following I18n messages in 'devise.sessions' " \
|
|
|
|
"are deprecated: #{keys.to_sentence}. Please move them to 'devise.failure' instead."
|
|
|
|
end
|
2010-04-03 07:11:45 -04:00
|
|
|
end
|
|
|
|
end
|
2010-02-16 08:57:10 -05:00
|
|
|
end
|
|
|
|
end
|