how make the Auth Component in cake redirect to login page and don't keep the previous route. Example, if I going to index the Auth component redirect to /users/login instead of /users/login?redirect=%2index Thanks.
Asked
Active
Viewed 34 times
0
ArAlM
- 1
- 1
-
follow this: https://stackoverflow.com/a/44263171/3278639 – Mustafa Sep 27 '17 at 13:54
1 Answers
0
Perhaps you should consider to not take into account the previous page and force redirect to a specific controller's action of your choice.
<?php
public function login()
{
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect(['controller' => 'YourController', 'action' => 'YourAction']);
}
$this->Flash->error(__('Invalid credentials.'));
}
}
?>
Guillaume Pommier
- 447
- 6
- 10
-
Yeah, I do that but doesn't works. He still redirect to the previous route. – ArAlM Sep 28 '17 at 21:47