Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/PhabricatorLogoutController.php
Show All 23 Lines | final class PhabricatorLogoutController | ||||
public function shouldAllowLegallyNonCompliantUsers() { | public function shouldAllowLegallyNonCompliantUsers() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$log = PhabricatorUserLog::initializeNewLog( | |||||
$viewer, | |||||
$viewer->getPHID(), | |||||
PhabricatorUserLog::ACTION_LOGOUT); | |||||
$log->save(); | |||||
// Destroy the user's session in the database so logout works even if | // Destroy the user's session in the database so logout works even if | ||||
// their cookies have some issues. We'll detect cookie issues when they | // their cookies have some issues. We'll detect cookie issues when they | ||||
// try to login again and tell them to clear any junk. | // try to login again and tell them to clear any junk. | ||||
$phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION); | $phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION); | ||||
if (strlen($phsid)) { | if (strlen($phsid)) { | ||||
$session = id(new PhabricatorAuthSessionQuery()) | $session = id(new PhabricatorAuthSessionQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withSessionKeys(array($phsid)) | ->withSessionKeys(array($phsid)) | ||||
->executeOne(); | ->executeOne(); | ||||
if ($session) { | if ($session) { | ||||
$session->delete(); | $engine = new PhabricatorAuthSessionEngine(); | ||||
$engine->logoutSession($viewer, $session); | |||||
} | } | ||||
} | } | ||||
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION); | $request->clearCookie(PhabricatorCookies::COOKIE_SESSION); | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI('/auth/loggedout/'); | ->setURI('/auth/loggedout/'); | ||||
} | } | ||||
Show All 12 Lines |