Module: Merb::Authentication::Mixins::SaltedUser::RDBClassMethods

Defined in:
lib/merb-auth-more/mixins/salted_user/relaxdb_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
17
18
19
20
21
22
23
24
25
26
# File 'lib/merb-auth-more/mixins/salted_user/relaxdb_salted_user.rb', line 6

def self.extended(base)
  base.class_eval do

    property :crypted_password

    if Merb::Authentication::Mixins::SaltedUser > base
      property :salt
    end

    before_save :password_checks

    def password_checks
      if password_required?
        return false unless !password.blank? && password == password_confirmation
      end
      encrypt_password
      true
    end

  end
end

Instance Method Details

#authenticate(login, password) ⇒ Object



28
29
30
31
32
# File 'lib/merb-auth-more/mixins/salted_user/relaxdb_salted_user.rb', line 28

def authenticate(, password)
   = Merb::Authentication::Strategies::Basic::Base.
  @u = all.sorted_by() { |q| q.key() }.first
  @u && @u.authenticated?(password) ? @u : nil
end