From df9d7188922567c820230a23b4a54c1cb10f5696 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Tue, 8 May 2018 14:27:38 -0300
Subject: [PATCH] Bug 20730: Move the authentication block before doing
 anything

No need to add more information here, it's self-explanatory...

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 serials/routing.pl | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/serials/routing.pl b/serials/routing.pl
index ad5fe380b6..c14205aaaf 100755
--- a/serials/routing.pl
+++ b/serials/routing.pl
@@ -51,6 +51,16 @@ my $date_selected = $query->param('date_selected');
 $date_selected ||= q{};
 my $dbh = C4::Context->dbh;
 
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => 'serials/routing.tt',
+        query           => $query,
+        type            => 'intranet',
+        authnotrequired => 0,
+        flagsrequired   => { serials => 'routing' },
+    }
+);
+
 if($op eq 'delete'){
     delroutingmember($routingid,$subscriptionid);
 }
@@ -84,15 +94,6 @@ foreach my $dateseq (@{$serialdates}) {
     push @{$dates}, $d;
 }
 
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => 'serials/routing.tt',
-				query => $query,
-				type => 'intranet',
-				authnotrequired => 0,
-				flagsrequired => {serials => 'routing'},
-				debug => 1,
-				});
-
 my $member_loop = [];
 for my $routing ( @routinglist ) {
     my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;
-- 
2.17.0