Bug 17153: Redirect to search when logging in from search

This patch is a fresh attempt at redirecting back to search
results after logging in on opac-search.pl

To test:
- Perform an OPAC search
- Login on opac-search.pl with the search results displayed
- The page is redirected to opac-user.pl
- Log out
- Apply the patch
- Perform a new OPAC search
- Note the URL query string
- Login on opac-search.pl with the search results displayed
- The opac-search.pl page should be displayed with the correct
  query string and the page should indicate a logged in status

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Followed the test plan and the patch works.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Lee Jamison 2018-05-30 00:26:56 +00:00 committed by Nick Clemens
parent 452c962b6e
commit fa25c45ffc
4 changed files with 24 additions and 0 deletions

View File

@ -301,6 +301,7 @@
<h3 id="modalLoginLabel">Log in to your account</h3>
</div>
<form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="modalAuth">
<input type="hidden" name="has-search-query" id="has-search-query" value="" />
<div class="modal-body">
[% IF ( shibbolethAuthentication ) %]
[% IF ( invalidShibLogin ) %]

View File

@ -594,6 +594,7 @@
[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %]
[% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") %][% END %]
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
[% Asset.js("js/authtoresults.js") %]
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %]
[% END %]<script>
//<![CDATA[

View File

@ -0,0 +1,10 @@
if (window.location.href.indexOf("opac-search.pl") > -1) {
// extract search params
var searchUrl = location.href;
var searchParams = searchUrl.substring(searchUrl.indexOf("?")+1);
// store search params in loginModal to pass back on redirect
var query = document.getElementById("has-search-query");
query.value = searchParams;
}

View File

@ -362,4 +362,16 @@ $template->param(
failed_holds => scalar $query->param('failed_holds'),
);
# if not an empty string this indicates to return
# back to the opac-results page
my $search_query = $query->param('has-search-query');
if ($search_query ne '') {
print $query->redirect(
-uri => "/cgi-bin/koha/opac-search.pl?$search_query",
-cookie => $cookie,
);
}
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };