Bug 24003: (follow-up) Add all userenv parameters
This patch makes the API set more userenv params than just the borrowernumber. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/auth_* => SUCCESS: All tests pass 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
This commit is contained in:
parent
7d20f2cdc3
commit
b3189e3369
|
|
@ -245,8 +245,7 @@ sub authenticate_api_request {
|
|||
C4::Context->interface('api');
|
||||
|
||||
if ( $user and !$cookie_auth ) { # cookie-auth sets this and more, don't mess with that
|
||||
C4::Context->_new_userenv( $user->borrowernumber );
|
||||
C4::Context->set_userenv( $user->borrowernumber );
|
||||
$c->_set_userenv( $user );
|
||||
}
|
||||
|
||||
if ( !$authorization and
|
||||
|
|
@ -486,4 +485,33 @@ sub _basic_auth {
|
|||
return Koha::Patrons->find({ userid => $user_id });
|
||||
}
|
||||
|
||||
=head3 _set_userenv
|
||||
|
||||
$c->_set_userenv( $patron );
|
||||
|
||||
Internal method that sets C4::Context->userenv
|
||||
|
||||
=cut
|
||||
|
||||
sub _set_userenv {
|
||||
my ( $c, $patron ) = @_;
|
||||
|
||||
my $library = $patron->library;
|
||||
|
||||
C4::Context->_new_userenv( $patron->borrowernumber );
|
||||
C4::Context->set_userenv(
|
||||
$patron->borrowernumber, # number,
|
||||
$patron->userid, # userid,
|
||||
$patron->cardnumber, # cardnumber
|
||||
$patron->firstname, # firstname
|
||||
$patron->surname, # surname
|
||||
$library->branchcode, # branch
|
||||
$library->branchname, # branchname
|
||||
$patron->flags, # flags,
|
||||
$patron->email, # emailaddress
|
||||
);
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue