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

(-)a/C4/ILSDI/Services.pm (-8 / +17 lines)
Lines 368-381 sub AuthenticatePatron { Link Here
368
    my $username = $cgi->param('username');
368
    my $username = $cgi->param('username');
369
    my $password = $cgi->param('password');
369
    my $password = $cgi->param('password');
370
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
370
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
371
    if ( $status ) {
371
372
        # Get the borrower
372
    return { code => 'PatronNotFound' } unless( $status );
373
        my $patron = Koha::Patrons->find( { userid => $userid } );
373
374
        return { id => $patron->borrowernumber };
374
    # Get the borrower
375
    }
375
    my $patron = Koha::Patrons->find( { userid => $userid } );
376
    else {
376
    my $response->{id} =  $patron->borrowernumber;
377
        return { code => 'PatronNotFound' };
377
    # Check passwd complexity against rules
378
    my ($is_valid, $error) = Koha::AuthUtils::is_password_valid( $password );
379
380
    unless( $is_valid ) {
381
        $response->{code} = 'PatronPasswordNotSecure';
382
        $response->{securePasswordLabel} = $error;
383
        my $minPasswordLength = C4::Context->preference('minPasswordLength');
384
        $response->{securePasswordPattern} = '.{'.$minPasswordLength.'}' if( $error eq 'too_short');
385
        $response->{securePasswordPattern} = '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{'.$minPasswordLength.'}' if( $error eq 'too_weak');
378
    }
386
    }
387
388
    return $response;
379
}
389
}
380
390
381
=head2 GetPatronInfo
391
=head2 GetPatronInfo
382
- 

Return to bug 23011