preserve the entire url with query string in redirects
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 7 Aug 2008 15:22:57 +0000 (15:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 7 Aug 2008 15:22:57 +0000 (15:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@10302 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/Proxy.pm

index 476f288..96f3db1 100644 (file)
@@ -77,8 +77,9 @@ sub handler {
 
        # push everyone to the secure site
        if (!$ssl_off && $url =~ /^http:/o) {
-               $url =~ s/^http:/https:/o;
-               print "Location: $url\n\n";
+        my $base = $cgi->url(-base=>1);
+               $base =~ s/^http:/https:/o;
+               print "Location: $base".$apache->unparsed_uri."\n\n";
                return Apache2::Const::OK;
        }
 
@@ -104,7 +105,7 @@ sub handler {
                $auth_ses = oils_login($u, $p, $ltype);
                if ($auth_ses) {
                        print $cgi->redirect(
-                               -uri=>$url,
+                               -uri=> $apache->unparsed_uri,
                                -cookie=>$cgi->cookie(
                                        -name=>'ses',
                                        -value=>$auth_ses,
@@ -113,12 +114,12 @@ sub handler {
                        );
                        return Apache2::Const::REDIRECT;
                } else {
-            return back_to_login($cgi);
+            return back_to_login($apache, $cgi);
         }
        }
 
        my $user = verify_login($auth_ses);
-    return back_to_login($cgi) unless $user;
+    return back_to_login($apache, $cgi) unless $user;
 
        $ws_ou ||= $user->home_ou;
 
@@ -129,16 +130,17 @@ sub handler {
                ->request('open-ils.actor.user.perm.check', $auth_ses, $user->id, $ws_ou, $perms)
                ->gather(1);
 
-       return back_to_login($cgi) if (@$failures > 0);
+       return back_to_login($apache, $cgi) if (@$failures > 0);
 
        # they're good, let 'em through
        return Apache2::Const::DECLINED;
 }
 
 sub back_to_login {
+    my $apache = shift;
     my $cgi = shift;
     print $cgi->redirect(
-        -uri=>$cgi->url,
+        -uri=>$apache->unparsed_uri,
         -cookie=>$cgi->cookie(
             -name=>'ses',
             -value=>'',