public function login() {
//$this->viewBuilder()->layout(‘vodadminlogin’);
$this->viewBuilder()->layout(‘home/homelayout’);
if ($this->request->is('post') || $this->request->query('provider')) {
$user = $this->Auth->identify();
if ($user) {
// User role wise redirect
if($user['role'] == 'Guest' || $user['role']== 'Creator'){
$session = $this->request->session();
$session->write('userdata', $user);
$this->Auth->setUser($user);
$url = $session->read('vurl');
if($user['role'] == 'Guest'):
if($url){
return $this->redirect(['controller'=>'pages','action'=>'video'.$url]);
}else{
return $this->redirect(['controller'=>'pages','action'=>'couchhome']);
}
else:
return $this->redirect('/users/');
endif;
}else{
$session = $this->request->session();
$session->write('userdata', $user);
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
}
$this->Flash->error(__('Invalid username or password, try again'));
}
}
when user login as guest he should be redirect according to condition i have written but it is redirecting to that login page only means redirect not working.
any help would be highly appreciate. Thanks