|
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 |
our (@ISA, @EXPORT_OK); |
38 |
our (@ISA, @EXPORT_OK); |
| 38 |
|
39 |
|
|
Lines 322-336
Others will be added here depending on the needs (for instance biblio does not e
Link Here
|
| 322 |
sub output_and_exit_if_error { |
323 |
sub output_and_exit_if_error { |
| 323 |
my ( $query, $cookie, $template, $params ) = @_; |
324 |
my ( $query, $cookie, $template, $params ) = @_; |
| 324 |
my $error; |
325 |
my $error; |
| 325 |
if ( $params and exists $params->{module} ) { |
326 |
if ($params->{module} eq 'CSRF_TOKEN_CHECK') { |
| 326 |
if ( $params->{module} eq 'members' ) { |
327 |
my $csrfcheck = Koha::Token->new->check_csrf( { |
| 327 |
my $logged_in_user = $params->{logged_in_user}; |
328 |
session_id => scalar $cookie, |
| 328 |
my $current_patron = $params->{current_patron}; |
329 |
token => scalar $params->{csrf_token}, |
| 329 |
if ( not $current_patron ) { |
330 |
}); |
| 330 |
$error = 'unknown_patron'; |
331 |
unless ($csrfcheck) { |
| 331 |
} |
332 |
$error = 'wrong_csrf_token'; |
| 332 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
333 |
} |
| 333 |
$error = 'cannot_see_patron_infos'; |
334 |
|
|
|
335 |
} else { |
| 336 |
if ( $params and exists $params->{module} ) { |
| 337 |
if ( $params->{module} eq 'members' ) { |
| 338 |
my $logged_in_user = $params->{logged_in_user}; |
| 339 |
my $current_patron = $params->{current_patron}; |
| 340 |
if ( not $current_patron ) { |
| 341 |
$error = 'unknown_patron'; |
| 342 |
} |
| 343 |
elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { |
| 344 |
$error = 'cannot_see_patron_infos'; |
| 345 |
} |
| 334 |
} |
346 |
} |
| 335 |
} elsif ( $params->{module} eq 'cataloguing' ) { |
347 |
} elsif ( $params->{module} eq 'cataloguing' ) { |
| 336 |
# We are testing the record to avoid additem to fetch the Koha::Biblio |
348 |
# We are testing the record to avoid additem to fetch the Koha::Biblio |
|
Lines 338-344
sub output_and_exit_if_error {
Link Here
|
| 338 |
$error = 'unknown_biblio' unless $params->{record}; |
350 |
$error = 'unknown_biblio' unless $params->{record}; |
| 339 |
} |
351 |
} |
| 340 |
} |
352 |
} |
| 341 |
|
|
|
| 342 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
353 |
output_and_exit( $query, $cookie, $template, $error ) if $error; |
| 343 |
return; |
354 |
return; |
| 344 |
} |
355 |
} |