Zend 2 with Doctrine 2 - 手动设置凭证可调用

时间:2013-12-03 05:08:22

标签: doctrine-orm zend-framework2

我正在尝试使用Zend Framework 2和Doctrine 2对用户进行身份验证。

如何在控制器的操作方法中设置或更改credentialCallable选项。

$adapter = $this->getAuthService()->getAdapter();
// how to set credentialCallable option here
$adapter->setIdentityValue($data['username']);
$adapter->setCredentialValue($data['password']);
$result = $this->getAuthService()->authenticate();

顺便说一句,我知道如何在配置文件中设置它。 (见文件https://github.com/doctrine/DoctrineModule/blob/master/docs/authentication.md

1 个答案:

答案 0 :(得分:1)

我认为这应该有效:

$options = new \DoctrineModule\Options\Authentication;
$options->setCredentialCallable(function (User $user, $passwordGiven) { //body });
$adapter->setOptions($options);
相关问题