Bug 41094: Fix search_anonymize_candidates, locked_account
We should not allow anonymizing patrons with failed login attempts when the pref FailedLoginAttempts has not been set. Test plan: Run the test again from the previous patch. This should pass now. Choose a patron with a positive value (say 55) in borrowers.login_attempts or modify one. (NOTE: This patron will be anonymized in the test plan.) Empty pref value for FailedLoginAttempts. Set PatronAnonymizeDelay to 1. Fill dateexpiry for this patron to yesterday. Run cleanupdatabase.pl -confirm -v and check if the patron was NOT anonymized. * Anonymized 0 patrons Now set FailedLoginAttempts to a value (say 55) so that the patron is considered as locked. (This unrealistic value is for testing only.) MAKE SURE that you will not be anonymizing more patrons than you like in the next step! (Set login_attempts to value < 55 for all other patrons.) Run cleanupdatabase.pl -confirm -v again and check if the patron was anonymized. * Anonymized 1 patrons Restore the changed pref values. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commit291c2f103d) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> (cherry picked from commit2fb7dab4a4) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
56cd6fd0f0
commit
b3d0db6e7b
|
|
@ -1803,9 +1803,11 @@ disabled.
|
|||
sub account_locked {
|
||||
my ($self) = @_;
|
||||
my $FailedLoginAttempts = C4::Context->preference('FailedLoginAttempts');
|
||||
return 1 if $FailedLoginAttempts
|
||||
and $self->login_attempts
|
||||
and $self->login_attempts >= $FailedLoginAttempts;
|
||||
return 1
|
||||
if $FailedLoginAttempts
|
||||
&& $FailedLoginAttempts > 0
|
||||
&& $self->login_attempts
|
||||
&& $self->login_attempts >= $FailedLoginAttempts;
|
||||
return 1 if ($self->login_attempts || 0) < 0; # administrative lockout
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,9 +268,13 @@ sub search_anonymize_candidates {
|
|||
my $str = $parser->format_datetime($dt);
|
||||
$cond->{dateexpiry} = { '<=' => $str };
|
||||
$cond->{anonymized} = 0; # not yet done
|
||||
if( $params->{locked} ) {
|
||||
my $fails = C4::Context->preference('FailedLoginAttempts') || 0;
|
||||
$cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
|
||||
my $fails = C4::Context->preference('FailedLoginAttempts');
|
||||
|
||||
if ( $params->{locked} && $fails && $fails > 0 ) { # $fails should actually not be negative btw
|
||||
$cond->{login_attempts} =
|
||||
[ -and => { '!=' => undef }, { -not_in => [ 0, 1 .. $fails - 1 ] } ]; # -not_in does not like undef
|
||||
} elsif ( $params->{locked} ) {
|
||||
$cond->{login_attempts} = -1;
|
||||
}
|
||||
return $class->search( $cond );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue