/** * Handles the redirect options. * * @param string $type Prefix for the array key, mostly "success" or "error" * @param array $options Options * @return mixed */ protected function _handleRedirect($type, $options) { if (isset($options[$type . 'RedirectUrl']) && $options[$type . 'RedirectUrl'] !== false) { $result = $this->_controller->redirect($options[$type . 'RedirectUrl']); return $this->_redirectResponse = $result; } return false; }
/** * Logout * * @param array $options Options array. * @return \Cake\Network\Response */ public function logout($options = []) { $options = Hash::merge($this->config('logout'), $options); $Auth = $this->_getAuthObject(); $user = $Auth->user(); if (empty($user)) { return $this->_controller->redirect($this->_controller->referer()); } $logoutRedirect = $Auth->logout(); if (is_null($options['successRedirectUrl'])) { $options['successRedirectUrl'] = $logoutRedirect; } return $this->handleFlashAndRedirect('success', $options); }