Revision 03256d87
Added by Marc Dequènes almost 16 years ago
- ID 03256d87787eac6b687e796174771c56453ee0f7
app/models/user.rb | ||
---|---|---|
|
||
class User < ActiveRecord::Base
|
||
validates_presence_of :login, :salt
|
||
validates_presence_of :password, :password_confirmation, :if => :password_changed?
|
||
validates_presence_of :password, :if => :password_changed?
|
||
validates_confirmation_of :password
|
||
validates_uniqueness_of :login
|
||
validates_uniqueness_of :real_name, :email, :allow_nil => true
|
||
... | ... | |
end
|
||
|
||
def self.authenticate(login, pass)
|
||
u=find(:first, :conditions => ["login = ?", login])
|
||
u = find(:first, :conditions => ["login = ?", login])
|
||
return nil if u.nil?
|
||
return u if self.encrypt(pass, u.salt) == u.hashed_password
|
||
nil
|
||
end
|
||
|
||
def password_changed?
|
||
self.new_record? or @password
|
||
self.new_record? or not @password.blank?
|
||
end
|
||
end
|
Also available in: Unified diff
[fix] improve password validation