Class: HaveAPI::CLI::Authentication::Basic
- Inherits:
-
Base
- Object
- Base
- HaveAPI::CLI::Authentication::Basic
show all
- Defined in:
- lib/haveapi/cli/authentication/basic.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, register, #save
Instance Method Details
#authenticate ⇒ Object
26
27
28
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 26
def authenticate
@communicator.authenticate(:basic, {user: @user, password: @password})
end
|
#options(opts) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 7
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
17
18
19
20
21
22
23
24
|
# File 'lib/haveapi/cli/authentication/basic.rb', line 17
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
|