From 6f914b6d9d2eb445929c59b2bdb6d43b8d0c0f5b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 31 May 2019 12:13:06 -0500 Subject: [PATCH] Bug 22990: Test if 'check' is passed and mimick existing pattern To ease future addition of checks Signed-off-by: Martin Renvoize --- C4/Output.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 3b42bfe14a..39fbfb0d89 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -347,14 +347,16 @@ sub output_and_exit_if_error { $error = 'unknown_biblio' unless $params->{record}; } } - elsif ( $params->{check} eq 'csrf_token' ) { - $error = 'wrong_csrf_token' - unless Koha::Token->new->check_csrf( - { - session_id => scalar $query->cookie('CGISESSID'), - token => scalar $query->param('csrf_token'), - } - ); + elsif ( $params and exists $params->{check} ) { + if ( $params->{check} eq 'csrf_token' ) { + $error = 'wrong_csrf_token' + unless Koha::Token->new->check_csrf( + { + session_id => scalar $query->cookie('CGISESSID'), + token => scalar $query->param('csrf_token'), + } + ); + } } output_and_exit( $query, $cookie, $template, $error ) if $error; return; -- 2.20.1