有没有什么办法来强制使用Zend_Auth的身份验证? [英] Is there any way to force authentication with Zend_Auth?

查看:237
本文介绍了有没有什么办法来强制使用Zend_Auth的身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Zend_Auth的和饼干/会话持久性的工作。我似乎无法弄清楚如何强制认证这一类。

有没有办法强迫Zend_Auth的相信它已经验证为用户?


解决方案

  Zend_Auth的::的getInstance() -  GT; getStorage() -  GT;写($身份);

其中, $身份将包含相同类型的生成结构/数据时,通过标准的机制,在用户登录。例如,在登录操作给这个样本code:

  $适配器= $这个 - > getAuthAdapter($形式 - >的GetValues​​());
$ AUTH = Zend_Auth的::的getInstance();
$结果= $ auth->身份验证($适配器);
如果($ result->的isValid()){
    //(...)
}

$ result-方式> getIdentity()将返回身份,如果有效

I am working with Zend_Auth and cookie/session persistence. I can't seem to figure out how to force an authentication with this class.

Is there any way to force Zend_Auth to believe it has authenticated as a user?

解决方案

Zend_Auth::getInstance()->getStorage()->write($identity);

Where $identity would contain the same type of structure/data that's generated when the user logs in through the standard mechanism. For instance, given this sample code in the login action:

$adapter = $this->getAuthAdapter($form->getValues());
$auth    = Zend_Auth::getInstance();
$result  = $auth->authenticate($adapter);
if ($result->isValid()) {
    // (...)
}

$result->getIdentity() would return the identity if valid.

这篇关于有没有什么办法来强制使用Zend_Auth的身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆