Class: Ums::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ums::User
- Defined in:
- app/models/ums/user.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.authenticate(name, password) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/ums/user.rb', line 10 def self.authenticate(name,password) user = self.find_by_name(name) if user expected_password = encrypted_password(password,user.salt) if user.hashed_password != expected_password || !user.is_enabled user = nil end end user end |
Instance Method Details
#password ⇒ Object
31 32 33 |
# File 'app/models/ums/user.rb', line 31 def password @password end |
#password=(pwd) ⇒ Object
35 36 37 38 39 40 |
# File 'app/models/ums/user.rb', line 35 def password=(pwd) @password = pwd return if pwd.blank? create_salt self.hashed_password = Ums::User.encrypted_password(pwd,self.salt) end |
#verify_password(password) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/models/ums/user.rb', line 21 def verify_password(password) expected_password = Ums::User.encrypted_password(password,self.salt) logger.debug("expected_password:"+expected_password+",hashed_password:"+self.hashed_password) if self.hashed_password == expected_password true else false end end |