From 507d48413d3d09866a37db81d2a856f9a0a7c6f9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 6 Oct 2022 14:38:42 +0100 Subject: [PATCH] Bug 31699: Add 'return' option to opac modal login This patch adds the option to trigger a redirect back to the current context after successful login using modal logins triggered from various places in the OPAC. To make use of this, simply add 'data-return="true"' to the modal trigger link. Signed-off-by: Martin Renvoize Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- koha-tmpl/opac-tmpl/bootstrap/js/global.js | 5 +++++ opac/opac-user.pl | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index 6f5ae95c3f..27fe084755 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -225,6 +225,11 @@ $(document).ready(function(){ $(".loginModal-trigger").on("click",function(e){ e.preventDefault(); + var button = $(this); + var context = button.data('return'); + if ( context ) { + $('#modalAuth').append(''); + } $("#loginModal").modal("show"); }); $("#loginModal").on("shown.bs.modal", function(){ diff --git a/opac/opac-user.pl b/opac/opac-user.pl index ba45ddd237..1b2aa815d2 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -424,4 +424,14 @@ if ($search_query) { ); } +# if not an empty string this indicates to return +# back to the page we triggered the login from +my $return = $query->param('return'); +if ( $return ) { + print $query->redirect( + -uri => $return, + -cookie => $cookie, + ); +} + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.39.5