public function logout()
{
$eventBefore = $this->dispatchEvent(UsersAuthComponent::EVENT_BEFORE_LOGOUT);
if (is_array($eventBefore->result)) {
return $this->redirect($eventBefore->result);
}
$this->request->session()->destroy();
$this->Flash->success(__d('CakeDC/Users', 'You\'ve successfully logged out'));
$eventAfter = $this->dispatchEvent(UsersAuthComponent::EVENT_AFTER_LOGOUT);
if (is_array($eventAfter->result)) {
return $this->redirect($eventAfter->result);
}
return $this->redirect($this->Auth->logout());
}