Class: User
Instance Attribute Summary collapse
-
#confirm_password ⇒ Object
writeonly
Sets the attribute confirm_password.
Class Method Summary collapse
- .authenticate(login, password) ⇒ Object
- .protected_attributes ⇒ Object
- .protected_attributes=(array) ⇒ Object
Instance Method Summary collapse
- #after_initialize ⇒ Object
- #authenticated?(password) ⇒ Boolean
- #confirm_password? ⇒ Boolean
- #forget_me ⇒ Object
- #remember_me ⇒ Object
- #sha1(phrase) ⇒ Object
Instance Attribute Details
#confirm_password=(value) ⇒ Object (writeonly)
Sets the attribute confirm_password
29 30 31 |
# File 'app/models/user.rb', line 29 def confirm_password=(value) @confirm_password = value end |
Class Method Details
.authenticate(login, password) ⇒ Object
44 45 46 47 |
# File 'app/models/user.rb', line 44 def self.authenticate(login, password) user = find_by_login(login) user if user && user.authenticated?(password) end |
.protected_attributes ⇒ Object
31 32 33 |
# File 'app/models/user.rb', line 31 def protected_attributes @protected_attributes ||= [:password, :password_confirmation, :email] end |
.protected_attributes=(array) ⇒ Object
35 36 37 |
# File 'app/models/user.rb', line 35 def protected_attributes=(array) @protected_attributes = array.map{|att| att.to_sym } end |
Instance Method Details
#after_initialize ⇒ Object
53 54 55 |
# File 'app/models/user.rb', line 53 def after_initialize @confirm_password = true end |
#authenticated?(password) ⇒ Boolean
49 50 51 |
# File 'app/models/user.rb', line 49 def authenticated?(password) self.password == sha1(password) end |
#confirm_password? ⇒ Boolean
57 58 59 |
# File 'app/models/user.rb', line 57 def confirm_password? @confirm_password end |
#forget_me ⇒ Object
65 66 67 |
# File 'app/models/user.rb', line 65 def forget_me update_attribute(:session_token, nil) end |
#remember_me ⇒ Object
61 62 63 |
# File 'app/models/user.rb', line 61 def remember_me update_attribute(:session_token, sha1(Time.now + Radiant::Config['session_timeout'].to_i)) unless self.session_token? end |
#sha1(phrase) ⇒ Object
40 41 42 |
# File 'app/models/user.rb', line 40 def sha1(phrase) Digest::SHA1.hexdigest("--#{salt}--#{phrase}--") end |