Sha256: 0b16efdf3ba302fd42cc8b79e2289692299f6487bc11804e0506d7292bd68d5a

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 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

    # dataserver: 'pbssrvr\sqlexpress',
    # port:       1433,
    # username:   'mklooth',
    # password:   'ToolHound'

    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 sign_out
      @connection.close if @connection
      @connection = nil
      # post "api/logout"
      # @me = nil
    end
    alias :logout :sign_out


  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.4 lib/toolhound-ruby/authentication.rb