cakephpauthenticationbefore-filter

CakePHP auth Pluggin redirect issue


I am using cakephp auth Plugin . After login what happening is . The default log-in page is set by defining the loginAction variable in the beforeFilter function in your UsersController or AppController. But if you have used plug-ins in your application, and if a user tries to access a controller action of a plug-in the user is redirected to an invalid page like this.

http://satyam.vakharia.com/plugin_name/users/login

BeforeFilter functionality is like this..

function beforeFilter() {
Security::setHash('md5');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'home', 'action' => 'index');
$this->Auth->loginError = 'Invalid Username or Password.';
$this->Auth->authError = "You are not authorized to access.";
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');

}


Solution

  • $this->Auth->loginAction = array('plugin' => false, 'controller' => 'users', 'action' => 'login');
    $this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'home', 'action' => 'index');
    $this->Auth->loginError = 'Invalid Username or Password.';
    $this->Auth->authError = "You are not authorized to access.";
    $this->Auth->logoutRedirect = array('plugin' => false, 'controller' => 'users', 'action' => 'login');
    

    There.