Dear all,
I have a strange issue when I use the
return redirect()->to() function:
In my controller; I have this method:
PHP Code:
private function _check_login()
{
$auth = service('simplecas');
$this->user = $auth->logged_in_user();
$this->data['user'] = $this->user;
if(!isset($this->user) || is_null($this->user))
{
//return redirect()->to('no_valid_userid');
return redirect()->route('no_valid_userid');
}
// Check if user id is in a given array of allowed uids
elseif(is_array($this->user) && !in_array($this->user['uid'], $this->allowed_uids))
{
//die('Not allowed');
//return redirect()->to('/issues/not_allowed');
return redirect()->route('not_allowed');
}
else
{
$this->data['user'] = $this->user;
}
}
In my routes config file, I added:
PHP Code:
$routes->add('not_allowed', 'Issues::not_allowed');
$routes->add('no_valid_userid', 'Issues::no_valid_userid');
Neither way of redirection (via 'route' or 'to' works), the code just continues no mather if the user is logged in or not.
If I uncomment the
die('Not allowed') line, it works (scrips stops).
Can anyone explain this behaviour? What am I doing wrong?
Many thanks in advance!