From d2f2590c894efca417112795e05248dbd16636f5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 4 Apr 2017 16:43:58 -0300 Subject: [PATCH] Bug 18403: Send logged_in_user to template from C4::Auth Technical note: To ease future changes we are passing a logged_in_user variable to templates. It contains the Koha::Patron object representing the logged in patron. This will be very useful for this patch and even after (for instance we will be able to replace easily loggedinusername and loggedinusernumber). Signed-off-by: Signed-off-by: Jon McGowan Signed-off-by: Jonathan Druart --- C4/Auth.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 7fac6df7d8..7903099bf4 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -213,26 +213,26 @@ sub get_template_and_user { # It's possible for $user to be the borrowernumber if they don't have a # userid defined (and are logging in through some other method, such # as SSL certs against an email address) - my $borrower; + my $patron; $borrowernumber = getborrowernumber($user) if defined($user); if ( !defined($borrowernumber) && defined($user) ) { - $borrower = Koha::Patrons->find( $user ); - if ($borrower) { - $borrower = $borrower->unblessed; + $patron = Koha::Patrons->find( $user ); + if ($patron) { $borrowernumber = $user; # A bit of a hack, but I don't know there's a nicer way # to do it. - $user = $borrower->{firstname} . ' ' . $borrower->{surname}; + $user = $patron->firstname . ' ' . $patron->surname; } } else { - $borrower = Koha::Patrons->find( $borrowernumber ); - $borrower->unblessed if $borrower; # FIXME Otherwise, what to do? + $patron = Koha::Patrons->find( $borrowernumber ); + # FIXME What to do if $patron does not exist? } # user info - $template->param( loggedinusername => $user ); - $template->param( loggedinusernumber => $borrowernumber ); + $template->param( loggedinusername => $user ); # FIXME Should be replaced with something like patron-title.inc + $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber + $template->param( logged_in_user => $patron ); $template->param( sessionID => $sessionID ); if ( $in->{'type'} eq 'opac' ) { @@ -254,7 +254,7 @@ sub get_template_and_user { ); } - $template->param( "USER_INFO" => $borrower ); + $template->param( "USER_INFO" => $patron->unblessed ); my $all_perms = get_all_subpermissions(); -- 2.39.5