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

(-)a/Koha/Patron.pm (-3 / +3 lines)
Lines 736-742 sub can_see_patrons_from { Link Here
736
    my $can = 0;
736
    my $can = 0;
737
    if ( $self->branchcode eq $branchcode ) {
737
    if ( $self->branchcode eq $branchcode ) {
738
        $can = 1;
738
        $can = 1;
739
    } elsif ( $self->can( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
739
    } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
740
        $can = 1;
740
        $can = 1;
741
    } elsif ( my $library_groups = $self->library->library_groups ) {
741
    } elsif ( my $library_groups = $self->library->library_groups ) {
742
        while ( my $library_group = $library_groups->next ) {
742
        while ( my $library_group = $library_groups->next ) {
Lines 773-779 sub libraries_where_can_see_patrons { Link Here
773
    }
773
    }
774
    else {
774
    else {
775
        unless (
775
        unless (
776
            $self->can(
776
            $self->has_permission(
777
                { borrowers => 'view_borrower_infos_from_any_libraries' }
777
                { borrowers => 'view_borrower_infos_from_any_libraries' }
778
            )
778
            )
779
          )
779
          )
Lines 798-804 sub libraries_where_can_see_patrons { Link Here
798
    return sort (@restricted_branchcodes);
798
    return sort (@restricted_branchcodes);
799
}
799
}
800
800
801
sub can {
801
sub has_permission {
802
    my ( $self, $flagsrequired ) = @_;
802
    my ( $self, $flagsrequired ) = @_;
803
    return unless $self->userid;
803
    return unless $self->userid;
804
    # TODO code from haspermission needs to be moved here!
804
    # TODO code from haspermission needs to be moved here!
(-)a/t/db_dependent/api/v1/patrons.t (-2 / +1 lines)
Lines 90-96 $tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . ($borrower->{ borrowernumber Link Here
90
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
90
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
91
$t->request_ok($tx)
91
$t->request_ok($tx)
92
  ->status_is(403)
92
  ->status_is(403)
93
  ->json_is('/required_permissions', {"borrowers" => "1"});
93
  ->json_is('/required_permissions', {"borrowers" => "edit_borrowers"});
94
94
95
# User without permissions, but is the owner of the object
95
# User without permissions, but is the owner of the object
96
$tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $borrower->{borrowernumber});
96
$tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $borrower->{borrowernumber});
97
- 

Return to bug 18403