Class: HaveAPI::CLI::Authentication::Basic

Inherits:
Base
  • Object
show all
Defined in:
lib/haveapi/cli/authentication/basic.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, register, #save

Constructor Details

This class inherits a constructor from HaveAPI::CLI::Authentication::Base

Instance Method Details

#authenticateObject



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

#validateObject



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