Sha256: 08f414918b2a3238e554f53bdf5e8adcf496e537461b324c065664efa09fadeb

Contents?: true

Size: 645 Bytes

Versions: 14

Compression:

Stored size: 645 Bytes

Contents

require 'haveapi/cli/authentication/base'

module HaveAPI::CLI::Authentication
  class Basic < Base
    register :basic

    def options(opts)
      opts.on('--user USER', 'User name') do |u|
        @user = u
      end

      opts.on('--password PASSWORD', 'Password') do |p|
        @password = p
      end
    end

    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

      nil
    end

    def authenticate
      @communicator.authenticate(:basic, { user: @user, password: @password })
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
haveapi-client-0.25.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.24.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.7 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.6 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.5 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.4 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.3 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.2 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.23.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.22.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.22.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.21.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.21.0 lib/haveapi/cli/authentication/basic.rb