diff --git a/src/Adapter/DbTable.php b/src/Adapter/DbTable.php index 867b8b1..df7eff0 100644 --- a/src/Adapter/DbTable.php +++ b/src/Adapter/DbTable.php @@ -369,6 +369,17 @@ public function authenticate() return $authResult; } + if (true === $this->getAmbiguityIdentity()) { + $validIdentities = array (); + $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match'); + foreach ($resultIdentities as $identity) { + if (1 === (int) $identity[$zendAuthCredentialMatchColumn]) { + $validIdentities[] = $identity; + } + } + $resultIdentities = $validIdentities; + } + $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities)); return $authResult; } diff --git a/test/Adapter/DbTableTest.php b/test/Adapter/DbTableTest.php index 43d36b6..d42e96f 100644 --- a/test/Adapter/DbTableTest.php +++ b/test/Adapter/DbTableTest.php @@ -429,6 +429,9 @@ public function testEqualUsernamesDifferentPasswordShouldAuthenticateWhenFlagIsS $this->assertTrue($result->isValid()); $this->assertEquals('my_username', $result->getIdentity()); + $this->_adapter = null; + $this->_setupAuthAdapter(); + // test if user 2 can authenticate $this->_adapter->setIdentity('my_username') ->setCredential('my_otherpass')