我正在尝试手动登录用户。
以前这是通过调用完成的$this->Auth->login()
我找不到使用身份验证插件的方法。
$this->Authentication->setIdentity($this->request->getData());
您可以通过执行以下操作手动登录用户通过获取要登录的用户数据来创建用户实体。通过使用setUser,我们最终可以设置用户并最终将他重定向到主页。
public function manualLogin()
{
$user = $this->Users->newEntity($this->request->getData());
$this->Auth->setUser($user->toArray());
return $this->redirect(['controller' => 'Home','action' => 'index' ]);
}