Sha256: 8f2d5bd4bfa06286a7b17c739f42ac8c6c1ef1931a0a549b818886dadb07a6ac

Contents?: true

Size: 636 Bytes

Versions: 15

Compression:

Stored size: 636 Bytes

Contents

require 'haveapi/cli/authentication/base'

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

    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

    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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
haveapi-client-0.16.3 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.16.2 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.16.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.16.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.15.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.15.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.14.2 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.14.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.14.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.13.3 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.13.2 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.13.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.13.0 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.12.1 lib/haveapi/cli/authentication/basic.rb
haveapi-client-0.12.0 lib/haveapi/cli/authentication/basic.rb