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

(-)a/C4/Auth.pm (+4 lines)
Lines 2072-2077 sub _dispatch { Link Here
2072
2072
2073
sub haspermission {
2073
sub haspermission {
2074
    my ( $userid, $flagsrequired ) = @_;
2074
    my ( $userid, $flagsrequired ) = @_;
2075
2076
    Koha::Exceptions::WrongParameter->throw('$flagsrequired should not be undef')
2077
      unless defined($flagsrequired);
2078
2075
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
2079
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
2076
    $sth->execute($userid);
2080
    $sth->execute($userid);
2077
    my $row = $sth->fetchrow();
2081
    my $row = $sth->fetchrow();
(-)a/Koha/REST/V1/Auth.pm (-1 / +1 lines)
Lines 189-195 sub authenticate_api_request { Link Here
189
        # Manually pass the remote_address to check_auth_cookie
189
        # Manually pass the remote_address to check_auth_cookie
190
        my $remote_addr = $c->tx->remote_address;
190
        my $remote_addr = $c->tx->remote_address;
191
        my ($status, $sessionID) = check_cookie_auth(
191
        my ($status, $sessionID) = check_cookie_auth(
192
                                                $cookie, undef,
192
                                                $cookie, '*',
193
                                                { remote_addr => $remote_addr });
193
                                                { remote_addr => $remote_addr });
194
        if ($status eq "ok") {
194
        if ($status eq "ok") {
195
            my $session = get_session($sessionID);
195
            my $session = get_session($sessionID);
(-)a/svc/members/search (-1 / +1 lines)
Lines 91-97 if ($has_permission) { Link Here
91
    my ( $permission, $subpermission ) = split /\./, $has_permission;
91
    my ( $permission, $subpermission ) = split /\./, $has_permission;
92
    my @patrons_with_permission;
92
    my @patrons_with_permission;
93
    for my $patron ( @{ $results->{patrons} } ) {
93
    for my $patron ( @{ $results->{patrons} } ) {
94
        my $perms = haspermission( $patron->{userid} );
94
        my $perms = haspermission( $patron->{userid}, '*' );
95
        if (   $perms->{superlibrarian} == 1
95
        if (   $perms->{superlibrarian} == 1
96
            or $perms->{$permission} == 1 )
96
            or $perms->{$permission} == 1 )
97
        {
97
        {
(-)a/t/db_dependent/Auth/haspermission.t (-2 / +13 lines)
Lines 20-26 Link Here
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
21
22
use Modern::Perl;
22
use Modern::Perl;
23
use Test::More tests => 3;
23
use Test::More tests => 4;
24
use Test::Exception;
24
25
25
use Koha::Database;
26
use Koha::Database;
26
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
Lines 70-75 $builder->build( Link Here
70
    }
71
    }
71
);
72
);
72
73
74
subtest 'undef top level tests' => sub {
75
76
    plan tests => 2;
77
78
    throws_ok { my $r = haspermission( $borr1->{userid} ); }
79
    'Koha::Exceptions::WrongParameter',
80
      'Exception thrown when missing $requiredflags';
81
    throws_ok { my $r = haspermission( $borr1->{userid}, undef ); }
82
    'Koha::Exceptions::WrongParameter', 'Exception thrown when explicit undef';
83
};
84
73
subtest 'scalar top level tests' => sub {
85
subtest 'scalar top level tests' => sub {
74
86
75
    plan tests => 3;
87
    plan tests => 3;
76
- 

Return to bug 22483