0

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

4

2 回答 2

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');
于 2013-10-05T13:39:55.777 回答
0

您可以基于 Zend_Auth 创建自己的身份验证类,方法是将其放在本地库中的某个位置并覆盖 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。

于 2013-07-26T12:51:46.893 回答