Permalink
Browse files

Updating docs and TODO.

  • Loading branch information...
1 parent 28a7f78 commit d26f90f72bb2f9652b365fcb5a008f6ae736d12f @carlosantoniodasilva carlosantoniodasilva committed Oct 20, 2009
Showing with 37 additions and 6 deletions.
  1. +15 −2 README.rdoc
  2. +3 −1 TODO
  3. +5 −2 lib/devise/active_record.rb
  4. +14 −1 lib/devise/models/rememberable.rb
View
@@ -12,6 +12,7 @@ Right now it's composed of four mainly modules:
* Authenticable: responsible for encrypting password and validating authenticity of a user while signing in.
* Confirmable: responsible for verifying whether an account is already confirmed to sign in, and to send emails with confirmation instructions.
* Recoverable: takes care of reseting the user password and send reset instructions.
+* Rememberable: manages generating and clearing token for remember the user from a saved cookie.
* Validatable: creates all needed validations for email and password. It's totally optional, so you're able to to customize validations by yourself.
== Dependencies
@@ -49,6 +50,15 @@ We're assuming here you want a User model. First of all you have to setup a migr
# required for recoverable
t.string :reset_password_token
+ # required for rememberable
+ t.string :remember_token
+
+You may also want to add some indexes to improve performance:
+
+ add_index :your_table, :email
+ add_index :your_table, :confirmation_token # for confirmable
+ add_index :your_table, :reset_password_token # for recoverable
+
Now let's setup a User model adding the devise line to have your authentication working:
class User < ActiveRecord::Base
@@ -66,8 +76,11 @@ This line adds devise authenticable automatically for you inside your User class
# Include authenticable + recoverable
devise :recoverable
- # Include authenticable + confirmable + recoverable + validatable
- devise :confirmable, :recoverable, :validatable
+ # Include authenticable + rememberable modules
+ devise :rememberable
+
+ # Include authenticable + confirmable + recoverable + rememberable + validatable
+ devise :confirmable, :recoverable, :rememberable, :validatable
# Same as above, include all of them
devise :all
View
@@ -1,4 +1,4 @@
-* Add remember me (with customizable time frame)
+* Add customizable time frame for remember me
* Create generators
* Allow stretches and pepper per model
@@ -32,3 +32,5 @@
* Add confirmation_sent_at for confirmable
* Add confirmable filters
* Sign user in automatically after confirming or changing it's password
+
+* Add remember me
@@ -13,11 +13,14 @@ module ActiveRecord
# # include authenticable + recoverable modules
# devise :recoverable
#
+ # # include authenticable + rememberable modules
+ # devise :rememberable
+ #
# # include authenticable + validatable modules
# devise :validatable
#
- # # include authenticable + confirmable + recoverable + validatable
- # devise :confirmable, :recoverable, :validatable
+ # # include authenticable + confirmable + recoverable + rememberable + validatable
+ # devise :confirmable, :recoverable, :rememberable, :validatable
#
# # shortcut to include all modules (same as above)
# devise :all
@@ -3,7 +3,20 @@
module Devise
module Models
- # Rememberable Module
+ # Rememberable manages generating and clearing token for remember the user
+ # from a saved cookie. Rememberable also has utility methods for dealing
+ # with serializing the user into the cookie and back from the cookie, trying
+ # to lookup the record based on the saved information.
+ # You probably wouldn't use rememberable methods directly, they are used
+ # mostly internally for handling the remember token.
+ # Examples:
+ #
+ # User.find(1).remember_me! # regenerating the token
+ # User.find(1).forget_me! # clearing the token
+ # # generating info to put into cookies
+ # User.serialize_into_cookie(user)
+ # # lookup the user based on the incoming cookie information
+ # User.serialize_from_cookie(cookie_string)
module Rememberable
def self.included(base)

0 comments on commit d26f90f

Please sign in to comment.