Sha256: 760a76c052b11605c87e9798ce60a6cf5d94a23c96fb679d0c7f812dc47bd369

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 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,
          timeout:    @timeout
        )
      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

12 entries across 12 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.37 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.36 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.35 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.34 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.33 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.32 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.31 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.30 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.29 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.28 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.27 lib/toolhound-ruby/authentication.rb
toolhound-ruby-1.0.26 lib/toolhound-ruby/authentication.rb