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

documentation tweaks for extend_remember_period

This commit is contained in:
Trevor Turk 2010-07-24 00:31:39 +08:00 committed by José Valim
parent 058d433f28
commit 2939a61a49
4 changed files with 22 additions and 15 deletions

View file

@ -89,15 +89,15 @@ module Devise
mattr_accessor :password_length mattr_accessor :password_length
@@password_length = 6..20 @@password_length = 6..20
# Time interval where the remember me token is valid. # The time the user will be remembered without asking for credentials again.
mattr_accessor :remember_for mattr_accessor :remember_for
@@remember_for = 2.weeks @@remember_for = 2.weeks
# If a valid remember token can be re-used between multiple browsers. # If true, a valid remember token can be re-used between multiple browsers.
mattr_accessor :remember_across_browsers mattr_accessor :remember_across_browsers
@@remember_across_browsers = true @@remember_across_browsers = true
# Extend remember period everytime the user sign up. # If true, extends the user's remember period when remembered via cookie.
mattr_accessor :extend_remember_period mattr_accessor :extend_remember_period
@@extend_remember_period = false @@extend_remember_period = false

View file

@ -18,11 +18,15 @@ module Devise
# blocked and will have to enter his credentials again. # blocked and will have to enter his credentials again.
# This configuration is also used to calculate the expires # This configuration is also used to calculate the expires
# time for the cookie created to remember the user. # time for the cookie created to remember the user.
# By default remember_for is 2.weeks. # 2.weeks by default.
# #
# remember_across_browsers: if a valid remember token can be re-used # remember_across_browsers: if true, a valid remember token can be
# between multiple browsers. # re-used between multiple browsers.
# By default remember_across_browsers is true. # True by default.
#
# extend_remember_period: if true, extends the user's remember period
# when remembered via cookie.
# False by default.
# #
# Examples: # Examples:
# #
@ -80,14 +84,14 @@ module Devise
protected protected
# We just don't generate a token if remember across browser is given, # Generate a token unless remember_across_browsers is true and there is
# a remember token exists or it was expired. # an existing remember_token or the existing remember_token has expried.
def generate_remember_token? #:nodoc: def generate_remember_token? #:nodoc:
!(self.class.remember_across_browsers && remember_token) || remember_expired? !(self.class.remember_across_browsers && remember_token) || remember_expired?
end end
# We always generate a timestamp if extend_remember_period is true. Besides that, # Generate a timestamp if extend_remember_period is true, if no remember_token
# we generate only if one does not exist or the current one expired. # exists, or if an existing remember token has expired.
def generate_remember_timestamp? #:nodoc: def generate_remember_timestamp? #:nodoc:
self.class.extend_remember_period || remember_created_at.nil? || remember_expired? self.class.extend_remember_period || remember_created_at.nil? || remember_expired?
end end

View file

@ -61,11 +61,11 @@ Devise.setup do |config|
# The time the user will be remembered without asking for credentials again. # The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks # config.remember_for = 2.weeks
# If a valid remember token can be re-used between multiple browsers. # If true, a valid remember token can be re-used between multiple browsers.
# config.remember_across_browsers = true # config.remember_across_browsers = true
# When true, extends remember period when user signs up via cookie. # If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = true # config.extend_remember_period = false
# ==> Configuration for :validatable # ==> Configuration for :validatable
# Range for password length # Range for password length

View file

@ -58,9 +58,12 @@ Devise.setup do |config|
# The time the user will be remembered without asking for credentials again. # The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks # config.remember_for = 2.weeks
# If a valid remember token can be re-used between multiple browsers. # If true, a valid remember token can be re-used between multiple browsers.
# config.remember_across_browsers = true # config.remember_across_browsers = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# ==> Configuration for :validatable # ==> Configuration for :validatable
# Range for password length # Range for password length
# config.password_length = 6..20 # config.password_length = 6..20