I have an issue like, in my account table delete flag column is there. So if I delete a user it will set as 1. And i can create new user with same mail id. At that time this code fails, there are two records with same mail id. Is there any way to give delete flag also like email. My module.config.php:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
)
)
),
'authentication' => array(
'orm_default' => array(
'object_manager' => 'Doctrine\ORM\EntityManager',
'identity_class' => 'Authentication\Entity\Account',
'identity_property' => 'email',
'credential_property' => 'password',
'credential_callable' => function(Account $account, $passwordGiven) {
$userPassword = new UserPassword();
$res = $userPassword->verify($account->getPassword(), $passwordGiven);
return $res && !$account->getDeleteFlag() && $account->getStatus();
},
),
)
)
I don't know if this works on ZF2, i'm currently working with ZF1, but I had kind of the same problem.
The solution was to write a custom Auth Adapter. This class implements
Zend_Auth_Adapter_Interfaceand requires theauthenticatemethod.In my implementation of
authenticateI have included the custom verification for a flag plus username and password.So, when I have to check an user:
Hope it helps since it's on ZF1.