Module: Sorcery::Model::TemporaryToken::ClassMethods

Defined in:
lib/sorcery/model/temporary_token.rb

Instance Method Summary collapse

Instance Method Details

#load_from_token(token, token_attr_name, token_expiration_date_attr) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/sorcery/model/temporary_token.rb', line 19

def load_from_token(token, token_attr_name, token_expiration_date_attr)
  return nil if token.blank?
  user = sorcery_adapter.find_by_token(token_attr_name,token)
  if !user.blank? && !user.send(token_expiration_date_attr).nil?
    return Time.now.in_time_zone < user.send(token_expiration_date_attr) ? user : nil
  end
  user
end