Class: User
- Inherits:
-
Object
- Object
- User
- Includes:
- DataMapper::Resource
- Defined in:
- lib/manband/user.rb
Overview
This class manages users in the database
Constant Summary collapse
- @@admin =
'admin'
Class Method Summary collapse
- .admin ⇒ Object
-
.init ⇒ Object
Creates a default admin account if it does not exists.
Instance Method Summary collapse
-
#authenticate(password) ⇒ Object
Check passwords password: user password @return: true if authentication is correct.
Class Method Details
.admin ⇒ Object
43 44 45 |
# File 'lib/manband/user.rb', line 43 def self.admin return @@admin end |
.init ⇒ Object
Creates a default admin account if it does not exists. Default password is admin
23 24 25 26 27 28 29 30 |
# File 'lib/manband/user.rb', line 23 def self.init admin = User.get(@@admin) if admin == nil uuid = UUID.new admin = User.new(:login => @@admin, :password => Digest::SHA1.hexdigest('admin')) admin.save end end |
Instance Method Details
#authenticate(password) ⇒ Object
Check passwords password: user password @return: true if authentication is correct
35 36 37 38 39 40 41 |
# File 'lib/manband/user.rb', line 35 def authenticate(password) shapwd = Digest::SHA1.hexdigest(password) if self.password == shapwd return true end return false; end |