From 2939a61a4923af5e179b0dac7117cddf1603c974 Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Sat, 24 Jul 2010 00:31:39 +0800 Subject: [PATCH] documentation tweaks for extend_remember_period --- lib/devise.rb | 6 +++--- lib/devise/models/rememberable.rb | 20 ++++++++++++-------- lib/generators/devise/templates/devise.rb | 6 +++--- test/rails_app/config/initializers/devise.rb | 5 ++++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/devise.rb b/lib/devise.rb index 31c0cf65..9190c9a5 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -89,15 +89,15 @@ module Devise mattr_accessor :password_length @@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 @@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 @@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 @@extend_remember_period = false diff --git a/lib/devise/models/rememberable.rb b/lib/devise/models/rememberable.rb index 958e9789..83612dc2 100644 --- a/lib/devise/models/rememberable.rb +++ b/lib/devise/models/rememberable.rb @@ -18,11 +18,15 @@ module Devise # blocked and will have to enter his credentials again. # This configuration is also used to calculate the expires # 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 - # between multiple browsers. - # By default remember_across_browsers is true. + # remember_across_browsers: if true, a valid remember token can be + # re-used between multiple browsers. + # True by default. + # + # extend_remember_period: if true, extends the user's remember period + # when remembered via cookie. + # False by default. # # Examples: # @@ -80,14 +84,14 @@ module Devise protected - # We just don't generate a token if remember across browser is given, - # a remember token exists or it was expired. + # Generate a token unless remember_across_browsers is true and there is + # an existing remember_token or the existing remember_token has expried. def generate_remember_token? #:nodoc: !(self.class.remember_across_browsers && remember_token) || remember_expired? end - # We always generate a timestamp if extend_remember_period is true. Besides that, - # we generate only if one does not exist or the current one expired. + # Generate a timestamp if extend_remember_period is true, if no remember_token + # exists, or if an existing remember token has expired. def generate_remember_timestamp? #:nodoc: self.class.extend_remember_period || remember_created_at.nil? || remember_expired? end diff --git a/lib/generators/devise/templates/devise.rb b/lib/generators/devise/templates/devise.rb index 93aee989..6878d17b 100644 --- a/lib/generators/devise/templates/devise.rb +++ b/lib/generators/devise/templates/devise.rb @@ -61,11 +61,11 @@ Devise.setup do |config| # The time the user will be remembered without asking for credentials again. # 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 - # When true, extends remember period when user signs up via cookie. - # config.extend_remember_period = true + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false # ==> Configuration for :validatable # Range for password length diff --git a/test/rails_app/config/initializers/devise.rb b/test/rails_app/config/initializers/devise.rb index f7feea98..5a340f43 100644 --- a/test/rails_app/config/initializers/devise.rb +++ b/test/rails_app/config/initializers/devise.rb @@ -58,9 +58,12 @@ Devise.setup do |config| # The time the user will be remembered without asking for credentials again. # 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 + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + # ==> Configuration for :validatable # Range for password length # config.password_length = 6..20