Browse files

Better handling of previously enabled Devise model deserialization

  • Loading branch information...
1 parent f6c06ac commit 411b565ccacf592db08cfb9bee83296166166baf @rosenfeld committed Apr 18, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/devise/rails/warden_compat.rb
View
14 lib/devise/rails/warden_compat.rb
@@ -21,17 +21,23 @@ def serialize(record)
end
def deserialize(keys)
- klass, *args = keys
+ klass_name, *args = keys
begin
- ActiveSupport::Inflector.constantize(klass).serialize_from_session(*args)
+ klass = ActiveSupport::Inflector.constantize(klass_name)
+ if klass.respond_to? :serialize_from_session
+ klass.serialize_from_session(*args)
+ else
+ Rails.logger.warn "[Devise] Stored serialized class #{klass_name} seems not to be Devise enabled anymore. Did you do that on purpose?"
+ nil
+ end
rescue NameError => e
if e.message =~ /uninitialized constant/
- Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass}"
+ Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass_name}"
nil
else
raise
end
end
end
-end
+end

0 comments on commit 411b565

Please sign in to comment.