Sha256: 242b5dff2f454ade81398f1c30a2fd8c0fabc2d68b700a2c4027984b8661fe37

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

module Exist
  module Authentication
    def api_key
      @token || ENV['EXIST_API_TOKEN']
    end

    def login!
      resp = client.post(
        'auth/simple-token/',
        username: @options[:username],
        password: @options[:password]
      )

      if resp.body && resp.body['token']
        @token = resp.body['token']
      else
        raise 'There was a problem authenticating with the API'
      end
    end

    def credentials_provided?
      @options[:username] && @options[:password]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exist-0.1.0.beta.6 lib/exist/authentication.rb