Module: Merb::Authentication::Mixins::SaltedUser::ARClassMethods

Defined in:
lib/heedley-merb-auth-with-account/mixins/salted_user/ar_salted_user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user/ar_salted_user.rb', line 6

def self.extended(base)
  base.class_eval do
    
    validates_presence_of     :password,                   :if => :password_required?
    validates_presence_of     :password_confirmation,      :if => :password_required?
    validates_confirmation_of :password,                   :if => :password_required?
    
    before_save :encrypt_password
  end # base.class_eval
          
end

Instance Method Details

#authenticate(login, password) ⇒ Object

self.extended



18
19
20
21
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user/ar_salted_user.rb', line 18

def authenticate(, password)
  @u = find(:first, :conditions => ["#{Merb::Authentication::Strategies::Basic::Base.} = ?", ])
  @u && @u.authenticated?(password) ? @u : nil
end