lib/casclient/responses.rb in rubycas-client-2.1.0 vs lib/casclient/responses.rb in rubycas-client-2.2.0
- old
+ new
@@ -86,15 +86,15 @@
end
end
def is_success?
- @valid == true || (protocol > 1.0 && xml.name == "authenticationSuccess")
+ (instance_variable_defined?(:@valid) && @valid) || (protocol > 1.0 && xml.name == "authenticationSuccess")
end
def is_failure?
- @valid == false || (protocol > 1.0 && xml.name == "authenticationFailure" )
+ (instance_variable_defined?(:@valid) && !@valid) || (protocol > 1.0 && xml.name == "authenticationFailure" )
end
end
# Represents a response from the CAS server to a proxy ticket request
# (i.e. after requesting a proxy ticket).
@@ -158,11 +158,13 @@
location = header['location'].first if header['location'] && header['location'].first
if location =~ /ticket=([^&]+)/
@ticket = $~[1]
end
- if !http_response.kind_of?(Net::HTTPSuccess) || ticket.blank?
+ if (http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?
+ log.info("Login was successful for ticket: #{@ticket.inspect}.")
+ else
@failure = true
# Try to extract the error message -- this only works with RubyCAS-Server.
# For other servers we just return the entire response body (i.e. the whole error page).
body = http_response.body
if body =~ /<div class="messagebox mistake">(.*?)<\/div>/m
@@ -184,6 +186,6 @@
end
end
class BadResponseException < CASException
end
-end
\ No newline at end of file
+end