Module: Devise::Models::RemoteAuthenticatable::ClassMethods

Defined in:
lib/devise/models/remote_authenticatable.rb

Overview

Overriden methods from Devise::Models::Authenticatable

Instance Method Summary collapse

Instance Method Details

#serialize_from_session(key, salt) ⇒ Object

This method is called from: Warden::SessionSerializer in devise

It takes as many params as elements had the array returned in serialize_into_session

Recreates a resource from session data



41
42
43
44
45
46
# File 'lib/devise/models/remote_authenticatable.rb', line 41

def serialize_from_session(key,salt)
  record = Rails.cache.fetch(['user', key], expires_in: 1.minutes) do
    to_adapter.get(key)
  end.tap {|r| r && r.clear_association_cache}
  record if record && record.authenticatable_salt == salt
end

#serialize_into_session(record) ⇒ Object

Here you have to return and array with the data of your resource that you want to serialize into the session

You might want to include some authentication data



52
53
54
# File 'lib/devise/models/remote_authenticatable.rb', line 52

def serialize_into_session(record)
  [record.to_key, record.authenticatable_salt]
end