Module: Typus::Orm::ActiveRecord::AdminUserV2::ClassMethods

Defined in:
lib/typus/orm/active_record/admin_user_v2.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(email, password) ⇒ Object



34
35
36
37
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 34

def authenticate(email, password)
  user = find_by_email_and_status(email, true)
  user && user.authenticate(password) ? user : nil
end

#has_adminObject



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
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 12

def has_admin

  extend Typus::Orm::ActiveRecord::User::ClassMethods

  include Typus::Orm::ActiveRecord::User::InstanceMethods
  include InstanceMethods

  attr_reader   :password
  attr_accessor :password_confirmation

  attr_protected :role, :status

  validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
  validates :password, :confirmation => true
  validates :password_digest, :presence => true

  validate :password_must_be_strong

  serialize :preferences

  before_save :set_token

  def authenticate(email, password)
    user = find_by_email_and_status(email, true)
    user && user.authenticate(password) ? user : nil
  end

end