diff --git a/security/MemberAuthenticator.php b/security/MemberAuthenticator.php index f03d4bbd4..0b30a2641 100755 --- a/security/MemberAuthenticator.php +++ b/security/MemberAuthenticator.php @@ -42,7 +42,7 @@ class MemberAuthenticator extends Authenticator { "Member", "\"Email\" = '$SQL_user' AND \"Password\" IS NOT NULL" ); - $result = $member->checkPassword($RAW_data['Password']); + $result = ($member) ? $member->checkPassword($RAW_data['Password']) : false; if($member && !$result->valid()) { $member->registerFailedLogin(); diff --git a/tests/security/MemberAuthenticatorTest.php b/tests/security/MemberAuthenticatorTest.php index b31250d66..e476b07f9 100644 --- a/tests/security/MemberAuthenticatorTest.php +++ b/tests/security/MemberAuthenticatorTest.php @@ -22,7 +22,8 @@ class MemberAuthenticatorTest extends SapphireTest { $member = DataObject::get_by_id('Member', $member->ID); $this->assertEquals($member->PasswordEncryption, "sha1_v2.4"); - $this->assertTrue($member->checkPassword('mypassword')); + $result = $member->checkPassword('mypassword'); + $this->assertTrue($result->valid()); } function testNoLegacyPasswordHashMigrationOnIncompatibleAlgorithm() { @@ -42,6 +43,7 @@ class MemberAuthenticatorTest extends SapphireTest { $member = DataObject::get_by_id('Member', $member->ID); $this->assertEquals($member->PasswordEncryption, "crc32"); - $this->assertTrue($member->checkPassword('mypassword')); + $result = $member->checkPassword('mypassword'); + $this->assertTrue($result->valid()); } } \ No newline at end of file diff --git a/tests/security/MemberTest.php b/tests/security/MemberTest.php index 2fc0047f4..190f66b9a 100644 --- a/tests/security/MemberTest.php +++ b/tests/security/MemberTest.php @@ -38,14 +38,16 @@ class MemberTest extends FunctionalTest { $member->PasswordEncryption, 'sha1_v2.4' ); - $this->assertTrue($member->checkPassword("mynewpassword")); + $result = $member->checkPassword('mynewpassword'); + $this->assertTrue($result->valid()); } function testSetPassword() { $member = $this->objFromFixture('Member', 'test'); $member->Password = "test1"; $member->write(); - $this->assertTrue($member->checkPassword("test1")); + $result = $member->checkPassword('test1'); + $this->assertTrue($result->valid()); } /** diff --git a/tests/security/SecurityTest.php b/tests/security/SecurityTest.php index e5608ed43..5adf20c5e 100644 --- a/tests/security/SecurityTest.php +++ b/tests/security/SecurityTest.php @@ -154,7 +154,7 @@ class SecurityTest extends FunctionalTest { /* THE FIRST 4 TIMES, THE MEMBER SHOULDN'T BE LOCKED OUT */ if($i < 5) { $this->assertNull($member->LockedOutUntil); - $this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORWRONGCRED'))); + $this->assertContains($this->loginErrorMessage(), _t('Member.ERRORWRONGCRED')); } /* AFTER THAT THE USER IS LOCKED OUT FOR 15 MINUTES */ @@ -165,7 +165,8 @@ class SecurityTest extends FunctionalTest { } if($i > 5) { - $this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORLOCKEDOUT'))); + $this->assertContains(_t('Member.ERRORLOCKEDOUT'), $this->loginErrorMessage()); + // $this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORLOCKEDOUT'))); } } diff --git a/tests/tasks/EncryptAllPasswordsTaskTest.php b/tests/tasks/EncryptAllPasswordsTaskTest.php index c37d35ef6..3eb7aa30b 100644 --- a/tests/tasks/EncryptAllPasswordsTaskTest.php +++ b/tests/tasks/EncryptAllPasswordsTaskTest.php @@ -16,6 +16,7 @@ class EncryptAllPasswordsTaskTest extends SapphireTest { $m = DataObject::get_by_id('Member', $m->ID); $this->assertEquals($m->PasswordEncryption, 'sha1_v2.4'); $this->assertNotEquals($m->Password, 'plain'); - $this->assertTrue($m->checkPassword('plain')); + $result = $m->checkPassword('plain'); + $this->assertTrue($result->valid()); } } \ No newline at end of file