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:
parent
f6c06ac786
commit
411b565cca
1 changed files with 10 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue