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

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

Return to bug 40286