Zend:覆盖"GetIdentity"?



我想更改zendAuth GetIdentity函数,以便它在返回结果之前更新会话。你会怎么做?

您可以基于Zend_Auth创建自己的Authentication类,方法是将其放在本地库中的某个位置并重写getIdentity(),例如

class Local_Auth extends Zend_Auth{
    public function getIdentity()
    {
        $storage = $this->getStorage();
        if ($storage->isEmpty()) {
            return null;
        }
        return $storage->read();
    }
}

然后,您只需实例化Local_Auth,而不是在身份验证过程中实例化Zend_Auth。

To Over Write getIdentity() in Authentication Class
Use  this Code,
Include this,
use ZendAuthentication,
ZendAuthenticationResult,
ZendAuthenticationAuthenticationService;
Create Instance for Authentication
$auth   = new AuthenticationService();
*****To Overwrite getStorage() in getIdentity()*****
$auth->getStorage()->write('Your Data');

最新更新