Class: Sinatra::Doorman::PasswordStrategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/doorman/base.rb

Overview

Base Features:

* Signup with Email Confirmation
* Login/Logout

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/doorman/base.rb', line 26

def authenticate!
  user = User.authenticate(
    params['user']['login'], 
    params['user']['password'])

  if user.nil?
    fail!(:login_bad_credentials)
  elsif !user.confirmed
    fail!(:login_not_confirmed)
  else
    success!(user)
  end
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/doorman/base.rb', line 20

def valid?
  params['user'] && 
    params['user']['login'] &&
    params['user']['password']
end