0
我想更改zendAuth GetIdentity函數,以便在返回結果之前更新會話。你會如何去做這件事?Zend:覆蓋「GetIdentity」?
我想更改zendAuth GetIdentity函數,以便在返回結果之前更新會話。你會如何去做這件事?Zend:覆蓋「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();
}
}
然後,而不是你的身份驗證過程實例Zend_Auth的,你只是實例Local_Auth代替。
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');