Skip to content

Commit

Permalink
Merge branch 'hotfix/issue-#248-zero-password-login' - fixes #248 - d…
Browse files Browse the repository at this point in the history
…iallows zero-password-login
  • Loading branch information
Ocramius committed May 16, 2013
2 parents 8be942c + 8effe76 commit 5f79a9f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function validateIdentity($identity)
$credentialValue = call_user_func($callable, $identity, $credentialValue);
}

if ($credentialValue !== true && $credentialValue != $documentCredential) {
if ($credentialValue !== true && $credentialValue !== $documentCredential) {
$this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
$this->authenticationResultInfo['messages'][] = 'Supplied credential is invalid.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,29 @@ public function testWillRefuseToAuthenticateWhenInvalidInstanceIsFound()

$adapter->authenticate();
}

public function testWillNotCastAuthCredentialValue()
{
$objectRepository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
$adapter = new ObjectRepositoryAdapter();
$entity = new IdentityObject();

$entity->setPassword(0);
$adapter->setOptions(
array(
'object_repository' => $objectRepository,
'credential_property' => 'password',
'identity_property' => 'username'
)
);
$adapter->setIdentity('a username');
$adapter->setCredential('00000');
$objectRepository
->expects($this->once())
->method('findOneBy')
->with($this->equalTo(array('username' => 'a username')))
->will($this->returnValue($entity));

$this->assertFalse($adapter->authenticate()->isValid());
}
}

0 comments on commit 5f79a9f

Please sign in to comment.