Always go back to the page you were on after logging in.
authorJan Urbański <[email protected]>
Thu, 26 Nov 2009 13:34:15 +0000 (08:34 -0500)
committerRobert Haas <[email protected]>
Thu, 26 Nov 2009 13:35:30 +0000 (08:35 -0500)
perl-lib/PgCommitFest/Request.pm
template/header.tt2

index a12ab4a633c5ab78a752de45cacdd632485e4d62..dc75d92b86fef842b7436ea024bc830a359e653b 100644 (file)
@@ -199,6 +199,17 @@ sub render_template {
        # reasonable if we've already begun sending the response back to Apache.
        my %stash;
        my $content = $self->generate_headers();
+       my $uri = '';
+       if ($ENV{'REQUEST_METHOD'} eq 'GET') {
+           if ($ENV{'SCRIPT_NAME'} ne '/action/login') {
+               my $req = $ENV{'REQUEST_URI'};
+               $req =~ s/[^A-Za-z0-9]/sprintf "%%%x", ord($&)/ge;;
+               $uri = '?uri=' . $req;
+           }
+           else {
+               $uri = '?' . $ENV{'QUERY_STRING'};
+           }
+       }
        %stash = %$vars if defined $vars;
        $stash{'authenticate'} = $self->authenticate();
        $stash{'control'} = $self->{'control'};
@@ -209,6 +220,7 @@ sub render_template {
                'title' => $self->{'title'},
                'error_list' => $self->{'error_list'},
                'script_name' => $ENV{'SCRIPT_NAME'},
+               'uri' => $uri,
        }, \$content) || die $template->error();
        $template->process($file . '.tt2', \%stash, \$content)
                || die $template->error();
index 4fd8018ef690a0ffb045a7230461e3c7443879ae..7e531a65b4ce1e793d9c64dc04ac346d7621951e 100644 (file)
@@ -17,7 +17,7 @@
     </td>
     <td id="commitfestNav">
        [% IF authenticate.userid.defined %]Welcome, [% authenticate.userid | htmlsafe %] - <a href='/action/logout'>Log Out</a>
-       [% ELSE %]<a href='/action/login'>Log In</a>
+        [% ELSE %]<a href='/action/login[% uri %]'>Log In</a>
        [% END %]
        - <a href='/'>Home Page</a>
     </td>