0

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.

ArAlM
  • 1
  • 1

1 Answers1

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.'));
    }
}
?>