Class: HaveAPI::CLI::Authentication::Basic
- Inherits:
-
Base
- Object
- Base
- HaveAPI::CLI::Authentication::Basic
show all
- Defined in:
- lib/haveapi/cli/authentication/basic.rb
Instance Attribute Summary
Attributes inherited from Base
#communicator
Instance Method Summary
collapse
Methods inherited from Base
#initialize, register, #save
Instance Method Details
#authenticate ⇒ Object
24
25
26
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 24
def authenticate
@communicator.authenticate(:basic, {user: @user, password: @password})
end
|
#options(opts) ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 5
def options(opts)
opts.on('--username USER', 'User name') do |u|
@user = u
end
opts.on('--password PASSWORD', 'Password') do |p|
@password = p
end
end
|
#validate ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 15
def validate
@user ||= ask('User name: ') { |q| q.default = nil }.to_s
@password ||= ask('Password: ') do |q|
q.default = nil
q.echo = false
end.to_s
end
|