Reputation: 115
Good Morning, I'm trying to allow access to an controller only if the user is redirected from an other controller.
if ($this->referer() !=
Router::url(array(
'controller'=>'customers', 'action'=>'register'
))) {
return $this->redirect(['controller'=>'customers','action'=>'register']);
}
But the above snippet always redirects me to customers/register.
I could not find anything in CakePHP documentation, so if anyone has an idea for me?
Upvotes: 0
Views: 173
Reputation: 824
$this->referer()
returns an URL, e.g. http://foo.localhost/controller/action
, while Router::url
returns a route only, e.g. /controller/action
.
Thus your condition does not match.
Upvotes: 1