Bug 20128: (QA follow-up) Corrections to haspermission
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 21 Mar 2019 10:16:34 +0000 (10:16 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 17 Apr 2019 12:25:26 +0000 (12:25 +0000)
The haspermission routine wrongly assumed that get_user_subpermissions
would return a list of all subpermissions if the user had the top level
permission, but instead if just returns 1.

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Auth.pm
t/db_dependent/Auth/haspermission.t

index 5a0df07..9ac819b 100644 (file)
@@ -2066,6 +2066,7 @@ sub _dispatch {
         }
     } elsif ($ref eq 'HASH') {
         foreach my $key (keys %{$required}) {
+            next if $flags == 1;
             my $require = $required->{$key};
             my $rflags  = $flags->{$key};
             return 0 unless _dispatch($require, $rflags);
@@ -2090,7 +2091,6 @@ sub _dispatch {
 sub haspermission {
     my ( $userid, $flagsrequired ) = @_;
 
-
     #Koha::Exceptions::WrongParameter->throw('$flagsrequired should not be undef')
     #  unless defined($flagsrequired);
 
index 0eb6c3c..064422b 100644 (file)
@@ -111,7 +111,7 @@ subtest 'scalar top level tests' => sub {
 
 subtest 'hashref top level AND tests' => sub {
 
-    plan tests => 15;
+    plan tests => 16;
 
     # Check top level permission for superlibrarian
     my $r =