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

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

Return to bug 23011