Lines 33-38
use Scalar::Util qw( looks_like_number );
Link Here
|
33 |
|
33 |
|
34 |
use C4::Context; |
34 |
use C4::Context; |
35 |
use C4::Templates; |
35 |
use C4::Templates; |
|
|
36 |
use Koha::Token; |
36 |
|
37 |
|
37 |
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
38 |
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
38 |
|
39 |
|
Lines 328-348
Others will be added here depending on the needs (for instance biblio does not e
Link Here
|
328 |
sub output_and_exit_if_error { |
329 |
sub output_and_exit_if_error { |
329 |
my ( $query, $cookie, $template, $params ) = @_; |
330 |
my ( $query, $cookie, $template, $params ) = @_; |
330 |
my $error; |
331 |
my $error; |
331 |
if ( $params and exists $params->{module} ) { |
332 |
if ($params->{module} eq 1) { |
332 |
if ( $params->{module} eq 'members' ) { |
333 |
$error = 'wrong_csrf_token'; |
333 |
my $logged_in_user = $params->{logged_in_user}; |
334 |
output_and_exit( $query, $cookie, $template, $error ) |
334 |
my $current_patron = $params->{current_patron}; |
335 |
unless Koha::Token->new->check_csrf( { |
335 |
if ( not $current_patron ) { |
336 |
session_id => scalar $cookie, |
336 |
$error = 'unknown_patron'; |
337 |
token => scalar $params->{csrf_token}, |
337 |
} |
338 |
}); |
338 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
339 |
} else { |
339 |
$error = 'cannot_see_patron_infos'; |
340 |
if ( $params and exists $params->{module} ) { |
|
|
341 |
if ( $params->{module} eq 'members' ) { |
342 |
my $logged_in_user = $params->{logged_in_user}; |
343 |
my $current_patron = $params->{current_patron}; |
344 |
if ( not $current_patron ) { |
345 |
$error = 'unknown_patron'; |
346 |
} |
347 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
348 |
$error = 'cannot_see_patron_infos'; |
349 |
} |
340 |
} |
350 |
} |
341 |
} |
351 |
} |
342 |
} |
|
|
343 |
|
352 |
|
344 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
353 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
345 |
return; |
354 |
return; |
|
|
355 |
} |
346 |
} |
356 |
} |
347 |
|
357 |
|
348 |
=item output_and_exit |
358 |
=item output_and_exit |