Zend framework Zend framework 3中的Authenticationservice
ZF3中的authenticationservice是否仍然可用?如果没有,新的名称是什么?它的工作原理相同吗 我收到错误消息: 找不到类“Import\AuthenticationService” 我请作曲家抓住它: 我也在zend-framework.com上搜索了它,但我也找不到任何关于迁移主题的信息 因为我来自ZF1,我也想问一下我的想法是否正确。我在Module.php中将Zend framework Zend framework 3中的Authenticationservice,zend-framework,zend-auth,zend-framework3,Zend Framework,Zend Auth,Zend Framework3,ZF3中的authenticationservice是否仍然可用?如果没有,新的名称是什么?它的工作原理相同吗 我收到错误消息: 找不到类“Import\AuthenticationService” 我请作曲家抓住它: 我也在zend-framework.com上搜索了它,但我也找不到任何关于迁移主题的信息 因为我来自ZF1,我也想问一下我的想法是否正确。我在Module.php中将authenticationService实现为工厂: 'factories' => [
authenticationService
实现为工厂:
'factories' => [
Model\Authentication::class => function ($container){
$auth = new AuthenticationService();
$dbAdapter = $container->get(AdapterInterface::class); // AND aktiv != 0
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 't_user','accessname','password', 'SHA2(?, 512)');
$auth->setAdapter($dbTableAuthAdapter);
return $auth;
},
Controller\IndexController::class => function($container) {
return new Controller\IndexController(
$container->get(Model\UserTable::class),
$container->get(Model\Authentication::class),
$container->get(AdapterInterface::class)
);
},
我将身份验证服务连接到我的控制器(Module.php):
我的Indexcontroller
如下所示:
class IndexController extends AbstractActionController
{
private $loginTable;
private $authService;
private $db;
public function __construct(UserTable $loginTable, AuthenticationService $authService, AdapterInterface $db)
{
//$db=$this->db ;
$this->loginTable = $loginTable;
$this->authService = $authService;
$this->db=$db;
}
//Anzeigen der importierten Dateien
public function indexAction()
{
$berechtigung = (int) $this->loginTable->getBerechtigung($this->authService->getIdentity());
if(!$this->authService->hasIdentity() || $berechtigung > 1){ // 1 = Administrator
return $this->redirect()->toRoute('user', ['action' => 'login']);
}
else {
return $this->redirect()->toRoute('project', ['action' => 'index']);
}
}
这是实现身份验证的正确方法吗 要安装zend身份验证,请在终端中键入此项
composer require zendframework/zend-authentication
关于你的错误信息,像这样
use Zend\Authentication\AuthenticationService;
找不到类“Import\AuthenticationService”
您应该像这样通过完整的名称空间来使用它
use Zend\Authentication\AuthenticationService;
要安装zend身份验证,请在终端中键入此项
composer require zendframework/zend-authentication
关于你的错误信息,像这样
use Zend\Authentication\AuthenticationService;
找不到类“Import\AuthenticationService”
您应该像这样通过完整的名称空间来使用它
use Zend\Authentication\AuthenticationService;
这是可行的,但在我的工厂中,我可能会遇到另一个问题,$dbTableAuthAdapter=newdbTableAuthAdapter($dbAdapter,'t_user','accessname','password');也找不到DbTableAuthAdapter,您知道为什么吗?将此添加到源代码
使用Zend\Authentication\Adapter\DbTable作为DbTableAuthAdapter
这是可行的,但在我的工厂中,我可能会遇到另一个问题,$dbTableAuthAdapter=newdbTableAuthAdapter($dbAdapter,'t_user','accessname','password');也找不到DbTableAuthAdapter,您知道为什么吗?将此添加到源代码使用Zend\Authentication\Adapter\DbTable作为DbTableAuthAdapter代码>