Class: Hapyrus::Command::Auth
- Inherits:
-
Base
- Object
- Base
- Hapyrus::Command::Auth
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
Instance Method Details
#ask_for_login ⇒ Object
4
5
6
7
8
|
# File 'lib/hapyrus/command/auth.rb', line 4
def ask_for_login
puts "Email:"; email = ask
puts "password:"; password = ask
hapyrus.credentials = Hapyrus::Credentials.new(email, password)
end
|
#display_login ⇒ Object
13
14
15
16
|
# File 'lib/hapyrus/command/auth.rb', line 13
def display_login
puts hapyrus.credentials.authenticated? ?
"Login successfully!" : "Email or password incorrect."
end
|
#login ⇒ Object
9
10
11
12
|
# File 'lib/hapyrus/command/auth.rb', line 9
def login
hapyrus.post('/users/sign_in')
hapyrus.credentials.authenticate! if hapyrus.response.code == 201 end
|