11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/typus/orm/active_record/admin_user_v1.rb', line 11
def enable_as_typus_user
extend Typus::Orm::ActiveRecord::User::ClassMethods
include Typus::Orm::ActiveRecord::User::InstanceMethods
include InstanceMethods
attr_accessor :password
attr_protected :role, :status
validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
validates :password,
:confirmation => { :if => :password_required? },
:presence => { :if => :password_required? }
validates_length_of :password, :within => 6..40, :if => :password_required?
validates :role, :presence => true
before_save :initialize_salt, :encrypt_password, :set_token
serialize :preferences
def self.authenticate(email, password)
user = find_by_email_and_status(email, true)
user && user.authenticated?(password) ? user : nil
end
end
|