From 716235b310e619485c212737432f9de26072f02d Mon Sep 17 00:00:00 2001 From: Lee Jamison Date: Mon, 22 Aug 2016 14:37:54 -0400 Subject: [PATCH] [SIGNED-OFF] Bug 17153: Logging in during a search should navigate back to search results Forces redirect to search results after logging in on opac-search.pl To test: - Perform a catalog or EDS search - Login from opac-search.pl - Without the patch, the page should redirect to opac-user.pl - Log out - Apply patch - Perform a search again - Login again from opac-search.pl - The page should redirect back to search results Signed-off-by: Aleisha Amohia --- C4/Output.pm | 12 ++++++++++-- opac/opac-user.pl | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index af7dd5a..6d110cf 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -43,13 +43,13 @@ BEGIN { %EXPORT_TAGS = ( all =>[qw(setlanguagecookie pagination_bar parametrized_url &output_with_http_headers &output_ajax_with_http_headers &output_html_with_http_headers)], ajax =>[qw(&output_with_http_headers &output_ajax_with_http_headers is_ajax)], - html =>[qw(&output_with_http_headers &output_html_with_http_headers)] + html =>[qw(&output_with_http_headers &output_html_with_http_headers &output_with_redirect)] ); push @EXPORT, qw( setlanguagecookie getlanguagecookie pagination_bar parametrized_url ); push @EXPORT, qw( - &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers + &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers &output_with_redirect ); } @@ -284,6 +284,14 @@ sub output_with_http_headers { print $query->header($options), $data; } +sub output_with_redirect { + my ( $query, $url, $cookie ) = @_; + print $query->redirect( + -URL => $url, + -COOKIE => $cookie, + ); +} + sub output_html_with_http_headers { my ( $query, $cookie, $data, $status, $extra_options ) = @_; output_with_http_headers( $query, $cookie, $data, 'html', $status, $extra_options ); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 0087a6a..266fe22 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -356,4 +356,9 @@ $template->param( failed_holds => scalar $query->param('failed_holds'), ); -output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; +if ( !$ENV{HTTP_REFERER} =~ /opac-search.pl/ || !$ENV{HTTP_REFERER} =~ /eds-search.pl/ ) { + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; +} +else { + output_with_redirect( $query, $ENV{HTTP_REFERER}, $cookie ); +} \ No newline at end of file -- 2.1.4