Bug 22483: (QA follow-up) Tweaking call to haspermission
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 8 Mar 2019 15:10:20 +0000 (15:10 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 8 Mar 2019 18:26:05 +0000 (15:26 -0300)
This patch tweaks the logic to check the permissions is defined before
passing to haspermission.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Koha/REST/V1/Auth.pm

index 92cafc2..53c6bac 100644 (file)
@@ -229,7 +229,7 @@ sub authenticate_api_request {
 
     my $permissions = $authorization->{'permissions'};
     # Check if the user is authorized
-    if ( haspermission($user->userid, $permissions)
+    if ( ( defined($permissions) and haspermission($user->userid, $permissions) )
         or allow_owner($c, $authorization, $user)
         or allow_guarantor($c, $authorization, $user) ) {