0

我正在尝试手动登录用户。

以前这是通过调用完成的$this->Auth->login()

我找不到使用身份验证插件的方法。

4

2 回答 2

1

 $this->Authentication->setIdentity($this->request->getData());

https://github.com/cakephp/authentication/issues/370

于 2020-07-21T10:03:18.143 回答
0

您可以通过执行以下操作手动登录用户通过获取要登录的用户数据来创建用户实体。通过使用setUser,我们最终可以设置用户并最终将他重定向到主页。

public function manualLogin()
{
    $user = $this->Users->newEntity($this->request->getData());
  
    $this->Auth->setUser($user->toArray());
    return $this->redirect(['controller' => 'Home','action' => 'index' ]);
}
于 2020-09-11T04:26:49.003 回答