Sha256: a3fcacfc6e02f0c2d2a0e6bd4e6d0e83d52566788477ecac1f8e38105b4f124e

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

module Toolhound

  # Authentication methods for {Toolhound::Client}
  module Authentication

    # Indicates if the client was supplied  Basic Auth
    # username and password
    #
    # @see
    # @return [Boolean]
    def authenticatable?
      !!(@username && @password && @dataserver)
    end


    def sign_in
      @connection ||= begin
        TinyTds::Client.new(
          dataserver: @dataserver,
          port:       @port,
          username:   @username,
          password:   @password
        )
      end

    end

    # def sign_in
    #
    #   response  = post 'auth/sign_in', { email: @email, password: @password}
    #   # update_headers(last_response && last_response.headers)
    #   reset_agent
    #   @me       = response && response[:data] #&& response[:data]
    # end
    # alias :login :sign_in

    # def update_headers(headers)
    #   headers ||= {}
    #   # puts "update"
    #   # last_response.headers
    #   @client_id    = headers["client"]
    #   @access_token = headers["access-token"]
    #   @expiry       = headers["expiry"]
    #   @uid          = headers["uid"]
    # end

    # Closes the current active session by expiring the ticket.
    #
    def reconnect
      sign_out
      sign_in
    end
    def sign_out
      @connection.close if @connection
      @connection = nil
      # post "api/logout"
      # @me = nil
    end
    alias :logout :sign_out


  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.14 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.13 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.12 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.11 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.10 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.9 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.8 lib/toolhound-ruby/authentication.rb