FIX Disallow negative values for FailedLoginCount (#10200)

This commit is contained in:
Steve Boyd 2022-01-14 11:29:49 +13:00 committed by GitHub
parent 465ca1d16d
commit cbf2987a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -937,6 +937,11 @@ class Member extends DataObject
$this->Locale = i18n::config()->get('default_locale'); $this->Locale = i18n::config()->get('default_locale');
} }
// Ensure FailedLoginCount is non-negative
if ($this->FailedLoginCount < 0) {
$this->FailedLoginCount = 0;
}
parent::onBeforeWrite(); parent::onBeforeWrite();
} }

View File

@ -1270,6 +1270,15 @@ class MemberTest extends FunctionalTest
} }
} }
public function testFailedLoginCountNegative()
{
/** @var Member $member */
$member = $this->objFromFixture(Member::class, 'test');
$member->FailedLoginCount = -1;
$member->write();
$this->assertSame(0, $member->FailedLoginCount);
}
public function testMemberValidator() public function testMemberValidator()
{ {
// clear custom requirements for this test // clear custom requirements for this test