From 1def090dc48c94c2722a2f97f0a86f5a89acb6ee Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 27 Jul 2007 19:27:29 +0000 Subject: [PATCH] ActionItem9: minor doc work --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index a0b7995..4053cc8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,10 +41,12 @@ class User < ActiveRecord::Base self.class.encrypt(password, salt) end + # returns +true+ if the +password+ is the correct one for the user def authenticated?(password) crypted_password == encrypt(password) end + # tells if the user has an authentication cookie def remember_token? remember_token_expires_at && Time.now.utc < remember_token_expires_at end @@ -56,6 +58,7 @@ class User < ActiveRecord::Base save(false) end + # throws the auth cookie away def forget_me self.remember_token_expires_at = nil self.remember_token = nil @@ -87,7 +90,9 @@ class User < ActiveRecord::Base self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? self.crypted_password = encrypt(password) end - + + # auxiliary method to test if a password must be supplied (i.e. returns + # +true+ when creating an user without supplying a password) def password_required? crypted_password.blank? || !password.blank? end -- libgit2 0.21.2