我在 Cloud 9 IDE 服务器上使用 Cakephp 3.2.11。
- 当我通过 Auth 组件注销我的应用程序时。我没有再次登录,但我尝试访问一些页面。出现 Auth session login request 像:(我没有设计它)
我在数据库的用户表中输入用户名和密码。它已登录。
现在,当我尝试注销时,销毁所有会话;我的应用程序仍然记录了我如上所述登录的会话。我使用调试来检查:
调试($this->request->session()->read('Auth'));
这是我的注销()
public function logout()
{
$this->request->session()->destroy();
return $this->redirect($this->Auth->logout());
}
我的 AppController.php 与 Auth 组件配置
$this->loadComponent('Auth', [
'authenticate' => array(
'Form' => array(
// 'fields' => array('username' => 'email'),
'scope' => array('is_delete' => '0')
)
),
'loginAction' => [
'controller' => 'MUsers',
'action' => 'login'
],
'authorize' => ['Controller'],
'loginRedirect' => [
'controller' => 'Pages',
'action' => 'dashboard'
],
'logoutRedirect' => [
'controller' => 'MUsers',
'action' => 'login'
],
'storage' => 'Session',
'authError' => 'Woopsie, you are not authorized to access this area.',
'flash' => [
'params' => [
'class' => 'alert alert-danger alert-dismissible text-c',
]
]
现在我无法使用代码删除该会话,我只能通过清除浏览器缓存来删除它。所以我的问题是:
如何使用代码或配置我的应用设置来解决此问题?
更新
根据@Kamlesh Gupta 的回答,它编辑了我的代码,没关系。
$this->loadComponent('Auth', [
'authenticate' => array(
'Form' => array(
'userModel' => 'MUsers', //Add this line
'fields' => array('username' => 'username',
'password' => 'password'), //Edited this line
'scope' => array('is_delete' => '0')
)
),
'loginAction' => [
'controller' => 'MUsers',
'action' => 'login'
],
'authorize' => ['Controller'],
'loginRedirect' => [
'controller' => 'Pages',
'action' => 'dashboard'
],
'logoutRedirect' => [
'controller' => 'MUsers',
'action' => 'login'
],
'storage' => 'Session',
'authError' => 'Woopsie, you are not authorized to access this area.',
'flash' => [
'params' => [
'class' => 'alert alert-danger alert-dismissible text-c',
]
]