Commit 1def090dc48c94c2722a2f97f0a86f5a89acb6ee

Authored by AntonioTerceiro
1 parent 114c4651

ActionItem9: minor doc work



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@194 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 6 additions and 1 deletions   Show diff stats
app/models/user.rb
... ... @@ -41,10 +41,12 @@ class User < ActiveRecord::Base
41 41 self.class.encrypt(password, salt)
42 42 end
43 43  
  44 + # returns +true+ if the +password+ is the correct one for the user
44 45 def authenticated?(password)
45 46 crypted_password == encrypt(password)
46 47 end
47 48  
  49 + # tells if the user has an authentication cookie
48 50 def remember_token?
49 51 remember_token_expires_at && Time.now.utc < remember_token_expires_at
50 52 end
... ... @@ -56,6 +58,7 @@ class User &lt; ActiveRecord::Base
56 58 save(false)
57 59 end
58 60  
  61 + # throws the auth cookie away
59 62 def forget_me
60 63 self.remember_token_expires_at = nil
61 64 self.remember_token = nil
... ... @@ -87,7 +90,9 @@ class User &lt; ActiveRecord::Base
87 90 self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
88 91 self.crypted_password = encrypt(password)
89 92 end
90   -
  93 +
  94 + # auxiliary method to test if a password must be supplied (i.e. returns
  95 + # +true+ when creating an user without supplying a password)
91 96 def password_required?
92 97 crypted_password.blank? || !password.blank?
93 98 end
... ...