@@ -67,7 +67,8 @@ def authenticate
67
67
cookie = res ? res . get_cookies : ''
68
68
# if we have creds, login with them
69
69
vprint_status ( 'Attempting Login' )
70
- res = send_request_cgi (
70
+ # the bang on the cgi will follow the redirect we receive on a good login
71
+ res = send_request_cgi! (
71
72
'uri' => normalize_uri ( target_uri . path , 'tiki-login.php' ) ,
72
73
'method' => 'POST' ,
73
74
'ctype' => 'application/x-www-form-urlencoded' ,
@@ -81,21 +82,11 @@ def authenticate
81
82
'stay_in_ssl_mode' => 'n'
82
83
}
83
84
)
84
- if res && res . redirect? && res . redirection . to_s . end_with? ( 'tiki-login_scr.php' )
85
+ # double check auth worked and we got a Log out on the page.
86
+ # at times I got it to auth, but then it would give permission errors
87
+ # so we want to try to double check everything is good
88
+ unless res . body =~ /Log out/
85
89
fail_with ( Failure ::UnexpectedReply , "#{ peer } Login Failed with #{ datastore [ 'USERNAME' ] } :#{ datastore [ 'PASSWORD' ] } " )
86
- elsif res && res . redirect?
87
- vprint_status ( "Verifying login... Visiting redirect to: #{ res . redirection } " )
88
- res = send_request_cgi (
89
- 'uri' => res . redirection . to_s ,
90
- 'method' => 'GET' ,
91
- 'cookie' => cookie
92
- )
93
- # double check auth worked and we got a Log out on the page.
94
- # at times I got it to auth, but then it would give permission errors
95
- # so we want to try to double check everything is good
96
- unless res . body =~ /Log out/
97
- fail_with ( Failure ::UnexpectedReply , "#{ peer } Login Failed with #{ datastore [ 'USERNAME' ] } :#{ datastore [ 'PASSWORD' ] } " )
98
- end
99
90
end
100
91
vprint_good ( "Login Successful!" )
101
92
return cookie
0 commit comments