From 45d67ed92e2ccc9c360cac90c8ac8d1138734a9b 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 --- 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 6f5ae95c3fa..27fe084755e 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 ba45ddd2379..1b2aa815d29 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.0