Class: User

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Class Method Details

.adminObject



43
44
45
# File 'lib/manband/user.rb', line 43

def self.admin
  return @@admin
end

.initObject

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