6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tpex/client/auth.rb', line 6
def login()
data = JSON.generate({"username" => username, "password" => password})
response_raw = post('user/login', data, true)
response = Response.create( response_raw.body )
@roles = response['user']['roles']
@cookie = "#{response["session_name"]}=#{response["sessid"]}"
bnes = ""
bni = ""
junkout = response_raw["set-cookie"].split(";")
junkout.each do |line|
if line =~ /BNES_SESS/
bnes = line.match(/(BNES_SESS.*)/)[0]
end
end
junkout.each do |line|
if line =~ /BNI/
bni = line.match(/(BNI.*)/)[0]
end
end
if bnes != ""
@cookie = @cookie + ';' + bnes
end
if bni != ""
@cookie = @cookie + ";" + bni
end
puts "COOKIES: #{@cookie}"
response
end
|