Lines 26-35
use Net::OAuth2::AuthorizationServer;
Link Here
|
26 |
use C4::Auth qw( check_cookie_auth get_session haspermission ); |
26 |
use C4::Auth qw( check_cookie_auth get_session haspermission ); |
27 |
use C4::Context; |
27 |
use C4::Context; |
28 |
|
28 |
|
|
|
29 |
use Koha::ApiKeys; |
29 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Lines; |
30 |
use Koha::Checkouts; |
31 |
use Koha::Checkouts; |
31 |
use Koha::Holds; |
32 |
use Koha::Holds; |
32 |
use Koha::OAuth; |
33 |
use Koha::OAuth; |
|
|
34 |
use Koha::OAuthAccessTokens; |
33 |
use Koha::Old::Checkouts; |
35 |
use Koha::Old::Checkouts; |
34 |
use Koha::Patrons; |
36 |
use Koha::Patrons; |
35 |
|
37 |
|
Lines 125-135
sub authenticate_api_request {
Link Here
|
125 |
); |
127 |
); |
126 |
|
128 |
|
127 |
if ($valid_token) { |
129 |
if ($valid_token) { |
128 |
my $clients = C4::Context->config('api_client'); |
130 |
my $patron_id = Koha::ApiKeys->single({ client_id => $valid_token->{client_id} })->patron_id; |
129 |
$clients = [ $clients ] unless ref $clients eq 'ARRAY'; |
131 |
my $patron = Koha::Patrons->find($patron_id); |
130 |
my ($client) = grep { $_->{client_id} eq $valid_token->{client_id} } @$clients; |
|
|
131 |
|
132 |
my $patron = Koha::Patrons->find($client->{patron_id}); |
133 |
my $permissions = $authorization->{'permissions'}; |
132 |
my $permissions = $authorization->{'permissions'}; |
134 |
# Check if the patron is authorized |
133 |
# Check if the patron is authorized |
135 |
if ( haspermission($patron->userid, $permissions) |
134 |
if ( haspermission($patron->userid, $permissions) |
136 |
- |
|
|