Recently I have upgraded cakephp 3.3.4 to cakephp 3.4.7, in old version If loggedin in current page it’s redirecting to current page only as I aspect, but after upgraded It’s redirecting into home page, I don’t know what’s the problem. please help me out here
In AppController:
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authorize' => ['Controller'],
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'email',
'password' => 'password'
],
'scope' => ['userStatus' => '1']
]
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'unauthorizedRedirect' => $this->referer(),
'logoutRedirect' => [
'controller' => 'Users',
'action' => 'login'
]
]);
}
login function:
public function login()
{
if($this->Auth->user()){
$this->Flash->error(__('You are already logged in!'));
return $this->redirect($this->Auth->redirectUrl());
}
else{
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error('Your username or password is incorrect.');
}
}
}