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

(-)a/C4/Auth.pm (-13 / +2 lines)
Lines 2178-2200 Missing POD for checkpw_internal. Link Here
2178
=cut
2178
=cut
2179
2179
2180
sub checkpw_internal {
2180
sub checkpw_internal {
2181
    my ( $userid, $password, $no_set_userenv ) = @_;
2181
    my ( $identifier, $password, $no_set_userenv ) = @_;
2182
2182
2183
    $password = Encode::encode( 'UTF-8', $password )
2183
    $password = Encode::encode( 'UTF-8', $password )
2184
        if Encode::is_utf8($password);
2184
        if Encode::is_utf8($password);
2185
2185
2186
    my $patron = Koha::Patrons->find( { userid => $userid } );
2186
    my $patron = Koha::Patrons->find_by_identifier($identifier);
2187
    if ($patron) {
2188
        if ( checkpw_hash( $password, $patron->password ) ) {
2189
            my $borrowernumber = $patron->borrowernumber;
2190
            C4::Context->set_userenv(
2191
                "$borrowernumber",  $patron->userid,  $patron->cardnumber,
2192
                $patron->firstname, $patron->surname, $patron->branchcode, $patron->library->branchname, $patron->flags
2193
            ) unless $no_set_userenv;
2194
            return 1, $patron->cardnumber, $patron->userid, $patron;
2195
        }
2196
    }
2197
    $patron = Koha::Patrons->find( { cardnumber => $userid } );
2198
    if ($patron) {
2187
    if ($patron) {
2199
        if ( checkpw_hash( $password, $patron->password ) ) {
2188
        if ( checkpw_hash( $password, $patron->password ) ) {
2200
            my $borrowernumber = $patron->borrowernumber;
2189
            my $borrowernumber = $patron->borrowernumber;
(-)a/t/db_dependent/Auth.t (-5 / +4 lines)
Lines 1650-1663 subtest 'checkpw for users with shared cardnumber / userid ' => sub { Link Here
1650
    my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } );
1650
    my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } );
1651
    $patron_2->set_password( { password => "PasswordTwo" } );
1651
    $patron_2->set_password( { password => "PasswordTwo" } );
1652
1652
1653
    my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->cardnumber, "OnePassword", undef, undef, 1 );
1653
    my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->userid, "OnePassword", undef, undef, 1 );
1654
    ok( $checkpw, 'checkpw returns true for right password when logging in via cardnumber' );
1654
    ok( $checkpw, 'checkpw returns true for right password when logging in via usrid' );
1655
    is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' );
1655
    is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' );
1656
    is( $userid,     $patron_1->userid,     'checkpw returns correct userid' );
1656
    is( $userid,     $patron_1->userid,     'checkpw returns correct userid' );
1657
    is( $patron->id, $patron_1->id,         'checkpw returns correct patron' );
1657
    is( $patron->id, $patron_1->id,         'checkpw returns correct patron' );
1658
1658
1659
    ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->userid, "PasswordTwo", undef, undef, 1 );
1659
    ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->cardnumber, "PasswordTwo", undef, undef, 1 );
1660
    ok( $checkpw, 'checkpw returns true for right password when logging in via userid' );
1660
    ok( $checkpw, 'checkpw returns true for right password when logging in via carndumber' );
1661
    is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' );
1661
    is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' );
1662
    is( $userid,     $patron_2->userid,     'checkpw returns correct userid' );
1662
    is( $userid,     $patron_2->userid,     'checkpw returns correct userid' );
1663
    is( $patron->id, $patron_2->id,         'checkpw returns correct patron' );
1663
    is( $patron->id, $patron_2->id,         'checkpw returns correct patron' );
1664
- 

Return to bug 40286