1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Better handling of previously enabled Devise model deserialization

This commit is contained in:
Rodrigo Rosenfeld Rosas 2012-04-18 15:29:13 -03:00
parent f6c06ac786
commit 411b565cca

View file

@ -21,17 +21,23 @@ class Warden::SessionSerializer
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