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.



162
163
164
165
# File 'lib/merb-auth/adapters/common.rb', line 162

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.



157
158
159
# File 'lib/merb-auth/adapters/common.rb', line 157

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

#make_keyObject



167
168
169
# File 'lib/merb-auth/adapters/common.rb', line 167

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