View | Details | Raw Unified | Return to bug 24003
Collapse All | Expand All

(-)a/Koha/REST/V1/Auth.pm (-3 / +30 lines)
Lines 248-255 sub authenticate_api_request { Link Here
248
    C4::Context->interface('api');
248
    C4::Context->interface('api');
249
249
250
    if ( $user and !$cookie_auth ) { # cookie-auth sets this and more, don't mess with that
250
    if ( $user and !$cookie_auth ) { # cookie-auth sets this and more, don't mess with that
251
        C4::Context->_new_userenv( $user->borrowernumber );
251
        $c->_set_userenv( $user );
252
        C4::Context->set_userenv( $user->borrowernumber );
253
    }
252
    }
254
253
255
    if ( !$authorization and
254
    if ( !$authorization and
Lines 489-492 sub _basic_auth { Link Here
489
    return Koha::Patrons->find({ userid => $user_id });
488
    return Koha::Patrons->find({ userid => $user_id });
490
}
489
}
491
490
491
=head3 _set_userenv
492
493
    $c->_set_userenv( $patron );
494
495
Internal method that sets C4::Context->userenv
496
497
=cut
498
499
sub _set_userenv {
500
    my ( $c, $patron ) = @_;
501
502
    my $library = $patron->library;
503
504
    C4::Context->_new_userenv( $patron->borrowernumber );
505
    C4::Context->set_userenv(
506
        $patron->borrowernumber, # number,
507
        $patron->userid,         # userid,
508
        $patron->cardnumber,     # cardnumber
509
        $patron->firstname,      # firstname
510
        $patron->surname,        # surname
511
        $library->branchcode,    # branch
512
        $library->branchname,    # branchname
513
        $patron->flags,          # flags,
514
        $patron->email,          # emailaddress
515
    );
516
517
    return $c;
518
}
519
492
1;
520
1;
493
- 

Return to bug 24003