Sha256: 70887820050af30a44299ee06416d3559733a6fd09ef52450c3a95de2b7db071
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require 'devise/strategies/base' module Devise module Strategies # Remember the user through the remember token. This strategy is responsible # to verify whether there is a cookie with the remember token, and to # recreate the user from this cookie if it exists. Must be called *before* # authenticatable. class Rememberable < Devise::Strategies::Base # A valid strategy for rememberable needs a remember token in the cookies. def valid? super && remember_me_cookie.present? end # To authenticate a user we deserialize the cookie and attempt finding # the record in the database. If the attempt fails, we pass to another # strategy handle the authentication. def authenticate! if resource = mapping.to.serialize_from_cookie(remember_me_cookie) success!(resource) else pass end end private # Accessor for remember cookie def remember_me_cookie @remember_me_cookie ||= request.cookies["remember_#{mapping.name}_token"] end end end end Warden::Strategies.add(:rememberable, Devise::Strategies::Rememberable)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
devise-0.9.2 | lib/devise/strategies/rememberable.rb |
devise-0.9.1 | lib/devise/strategies/rememberable.rb |
devise-0.9.0 | lib/devise/strategies/rememberable.rb |