public function beforeFilter(Event $event)
{
$user = $this->Auth->user();
if (!empty($user) || $this->request->is(['post', 'put']) || $this->request->action === 'logout' || $this->request->session()->check(Configure::read('Users.Key.Session.social')) || $this->request->param('provider')) {
return;
}
$user = $this->Auth->identify();
//No user no cookies
if (empty($user)) {
return;
}
$this->Auth->setUser($user);
$event = $this->_registry->getController()->dispatchEvent(UsersAuthComponent::EVENT_AFTER_COOKIE_LOGIN);
if (is_array($event->result)) {
return $this->_registry->getController()->redirect($event->result);
}
$url = $this->Auth->redirectUrl();
return $this->_registry->getController()->redirect($url);
}