Module: Toolhound::Authentication

Included in:
Client
Defined in:
lib/toolhound-ruby/authentication.rb

Overview

Authentication methods for Client

Instance Method Summary collapse

Instance Method Details

#authenticatable?Boolean

Indicates if the client was supplied Basic Auth username and password

Returns:

  • (Boolean)

See Also:



11
12
13
# File 'lib/toolhound-ruby/authentication.rb', line 11

def authenticatable?
  !!(@username && @password && @dataserver)
end

#reconnectObject

Closes the current active session by expiring the ticket.



50
51
52
53
# File 'lib/toolhound-ruby/authentication.rb', line 50

def reconnect
  sign_out
  
end

#sign_inObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/toolhound-ruby/authentication.rb', line 16

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

end

#sign_outObject Also known as: logout



54
55
56
57
58
59
# File 'lib/toolhound-ruby/authentication.rb', line 54

def sign_out
  @connection.close if @connection
  @connection = nil
  # post "api/logout"
  # @me = nil
end