Bug 9044: (follow-up) fix merge conflict typo that broke this script
[koha.git] / C4 / Auth_with_cas.pm
index 2e8e0b6..46cb1ec 100644 (file)
@@ -22,7 +22,6 @@ use warnings;
 
 use C4::Debug;
 use C4::Context;
-use C4::Utils qw( :all );
 use Authen::CAS::Client;
 use CGI;
 use FindBin;
@@ -91,10 +90,8 @@ sub login_cas {
 sub login_cas_url {
 
     my ($query, $key) = @_;
-    my $uri = C4::Context->preference('OPACBaseURL') . $query->script_name();
+    my $uri = C4::Context->preference('OPACBaseURL') . $query->url( -absolute => 1, -query => 1 );
     my $casparam = $query->param('cas');
-    # FIXME: This should be more generic and handle whatever parameters there might be
-    $uri .= "?cas=" . $casparam if (defined $casparam);
     $casparam = $defaultcasserver if (not defined $casparam);
     $casparam = $key if (defined $key);
     my $cas = Authen::CAS::Client->new($casservers->{$casparam});
@@ -145,7 +142,10 @@ sub checkpw_cas {
             $debug and warn "User $userid is not a valid Koha user";
 
         } else {
-            $debug and warn "Invalid session ticket : $ticket";
+            $debug and warn "Problem when validating ticket : $ticket";
+            $debug and warn "Authen::CAS::Client::Response::Error: " . $val->error() if $val->is_error();
+            $debug and warn "Authen::CAS::Client::Response::Failure: " . $val->message() if $val->is_failure();
+            $debug and warn Data::Dumper::Dumper($@) if $val->is_error() or $val->is_failure();
             return 0;
         }
     }