Class: Hapyrus::Command::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/hapyrus/command/auth.rb

Instance Method Summary collapse

Methods inherited from Base

#ask, #display_index, #display_show, #hapyrus, #index, #initialize, #show

Constructor Details

This class inherits a constructor from Hapyrus::Command::Base

Instance Method Details

#ask_for_loginObject



4
5
6
7
8
# File 'lib/hapyrus/command/auth.rb', line 4

def 
  puts "Email:"; email = ask
  puts "password:"; password = ask
  hapyrus.credentials = Hapyrus::Credentials.new(email, password)
end

#display_loginObject



13
14
15
16
# File 'lib/hapyrus/command/auth.rb', line 13

def 
  puts hapyrus.credentials.authenticated? ?
    "Login successfully!" : "Email or password incorrect."
end

#loginObject



9
10
11
12
# File 'lib/hapyrus/command/auth.rb', line 9

def 
  hapyrus.post('/users/sign_in')
  hapyrus.credentials.authenticate! if hapyrus.response.code == 201 # 201: Created
end