Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/user.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
-
.authenticate(login, pass) ⇒ Object
Authenticate.
Instance Method Summary collapse
- #is_admin ⇒ Object
- #is_webmaster ⇒ Object
-
#send_new_password ⇒ Object
Called if the user forgets their password; sets it to a random one, emails that to the user’s email address.
Instance Attribute Details
#password ⇒ Object
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(login, pass) u = find(:first, :conditions=>["login = ?", login]) return nil if u.nil? return u if User.encrypt(pass, u.salt) == u.crypted_password return nil end |
Instance Method Details
#is_admin ⇒ Object
35 36 37 |
# File 'app/models/user.rb', line 35 def is_admin return self.role <= 1 end |
#is_webmaster ⇒ Object
31 32 33 |
# File 'app/models/user.rb', line 31 def is_webmaster return self.role == 0 end |
#send_new_password ⇒ Object
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.login, new_pass) end |