good afternoon & happy launch with coffee.
I have trouble when users have complete logout, while their try login it’s shown autofill email and password. Here’s below sample code in my AppController.php
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
//theme nasa
$this->viewBuilder()->setTheme('Nasa');
//autentikasi
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authorize' => 'Controller',
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'Email',
'password' => 'Password'
]
]
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'logoutRedirect' => [
'controller' => 'Users',
'action' => 'login'
],
//jika tidak sah, maka alihkan
'unauthorizedRedirect' => $this->referer()
]);
//izinkan membaca
$this->Auth->allow(['beranda', 'view', 'index']);
}
public function beforeFilter(Event $event)
{
$this->Auth->allow(['beranda', 'view', 'index']);
}
public function beforeRender(Event $event)
{
parent::beforeFilter($event);
$this->set('userInfo', $this->Auth->user());
}
I was browsing in stackoverflow
https://stackoverflow.com/questions/39074881/cakephp-3-auth-session-cannot-destroy
and applying in my AppController.php
code below
public function logout()
{
$this->Auth->logout();
}
The result autofill email & password after logout still working, that could be dangerous in my app.
I hope someone help me to fix destroy autofill when logout, thanx for help