Lines 33-38
use Scalar::Util qw( looks_like_number );
Link Here
|
33 |
use C4::Auth qw(get_template_and_user); |
33 |
use C4::Auth qw(get_template_and_user); |
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 331-345
Others will be added here depending on the needs (for instance biblio does not e
Link Here
|
331 |
sub output_and_exit_if_error { |
332 |
sub output_and_exit_if_error { |
332 |
my ( $query, $cookie, $template, $params ) = @_; |
333 |
my ( $query, $cookie, $template, $params ) = @_; |
333 |
my $error; |
334 |
my $error; |
334 |
if ( $params and exists $params->{module} ) { |
335 |
if ($params->{module} eq 'CSRF_TOKEN_CHECK') { |
335 |
if ( $params->{module} eq 'members' ) { |
336 |
my $csrfcheck = Koha::Token->new->check_csrf( { |
336 |
my $logged_in_user = $params->{logged_in_user}; |
337 |
session_id => scalar $cookie, |
337 |
my $current_patron = $params->{current_patron}; |
338 |
token => scalar $params->{csrf_token}, |
338 |
if ( not $current_patron ) { |
339 |
}); |
339 |
$error = 'unknown_patron'; |
340 |
unless ($csrfcheck) { |
340 |
} |
341 |
$error = 'wrong_csrf_token'; |
341 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
342 |
} |
342 |
$error = 'cannot_see_patron_infos'; |
343 |
|
|
|
344 |
} else { |
345 |
if ( $params and exists $params->{module} ) { |
346 |
if ( $params->{module} eq 'members' ) { |
347 |
my $logged_in_user = $params->{logged_in_user}; |
348 |
my $current_patron = $params->{current_patron}; |
349 |
if ( not $current_patron ) { |
350 |
$error = 'unknown_patron'; |
351 |
} |
352 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
353 |
$error = 'cannot_see_patron_infos'; |
354 |
} |
343 |
} |
355 |
} |
344 |
} elsif ( $params->{module} eq 'cataloguing' ) { |
356 |
} elsif ( $params->{module} eq 'cataloguing' ) { |
345 |
# We are testing the record to avoid additem to fetch the Koha::Biblio |
357 |
# We are testing the record to avoid additem to fetch the Koha::Biblio |
Lines 347-353
sub output_and_exit_if_error {
Link Here
|
347 |
$error = 'unknown_biblio' unless $params->{record}; |
359 |
$error = 'unknown_biblio' unless $params->{record}; |
348 |
} |
360 |
} |
349 |
} |
361 |
} |
350 |
|
|
|
351 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
362 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
352 |
return; |
363 |
return; |
353 |
} |
364 |
} |