我想更改zendAuth GetIdentity函数,以便在返回结果之前更新会话。你会怎么做呢?
答案 0 :(得分:0)
您可以基于Zend_Auth创建自己的Authentication类,方法是将其放在本地库中并重写getIdentity(),例如
。class Local_Auth extends Zend_Auth{
public function getIdentity()
{
$storage = $this->getStorage();
if ($storage->isEmpty()) {
return null;
}
return $storage->read();
}
}
然后,您需要在身份验证过程中实例化Zend_Auth,而不是实例化Local_Auth。
答案 1 :(得分:0)
To Over Write getIdentity() in Authentication Class
Use this Code,
Include this,
use Zend\Authentication,
Zend\Authentication\Result,
Zend\Authentication\AuthenticationService;
Create Instance for Authentication
$auth = new AuthenticationService();
*****To Overwrite getStorage() in getIdentity()*****
$auth->getStorage()->write('Your Data');