Module: Impresser::Authenticate::ClassMethods

Defined in:
lib/impresser/mixin/authenticate.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(login, password) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/impresser/mixin/authenticate.rb', line 19

def authenticate(, password)
  user = find_user_for_authentication()
  if user && hasher.check(password, user.user_pass)
    return user
  else
    return nil
  end
end

#find_user_for_authentication(login) ⇒ Object

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/impresser/mixin/authenticate.rb', line 11

def find_user_for_authentication()
  raise NotImplementedError, "Your User class must implement the find_user_for_authentication method"
end

#hasherObject



15
16
17
# File 'lib/impresser/mixin/authenticate.rb', line 15

def hasher
  @hasher ||= Phpass.new
end