Class: User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



14
15
16
# File 'app/models/user.rb', line 14

def password
  @password
end

Class Method Details

.authenticate(login, pass) ⇒ Object

Authenticate



24
25
26
27
28
29
# File 'app/models/user.rb', line 24

def self.authenticate(, pass)
    u = find(:first, :conditions=>["login = ?", ])
    return nil if u.nil?
    return u if User.encrypt(pass, u.salt) == u.crypted_password
    return nil
end

Instance Method Details

#is_adminObject



35
36
37
# File 'app/models/user.rb', line 35

def is_admin
    return self.role <= 1
end

#is_webmasterObject



31
32
33
# File 'app/models/user.rb', line 31

def is_webmaster
    return self.role == 0
end

#send_new_passwordObject

Called if the user forgets their password; sets it to a random one, emails that to the user’s email address



40
41
42
43
44
45
# File 'app/models/user.rb', line 40

def send_new_password
    new_pass = User.random_string(10)
    self.password = self.password_confirmation = new_pass
    self.save
    Notifications.deliver_forgot_password(self.email, self., new_pass)
end