Module: MerbAuth::Adapter::Common::ClassMethods

Defined in:
lib/merb-auth/adapters/common.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(field, password) ⇒ Object

Authenticates a user by their login field and unencrypted password. Returns the user or nil.



148
149
150
151
# File 'lib/merb-auth/adapters/common.rb', line 148

def authenticate(field, password)
  @u = find_active_with_conditions(MA[:login_field] => field)
  @u = @u && @u.authenticated?(password) ? @u : nil
end

#encrypt(password, salt) ⇒ Object

Encrypts some data with the salt.



143
144
145
# File 'lib/merb-auth/adapters/common.rb', line 143

def encrypt(password, salt)
  Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end

#make_keyObject



153
154
155
# File 'lib/merb-auth/adapters/common.rb', line 153

def make_key
  Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
end