1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/applications/auth/controller/PhabricatorLogoutController.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2011-01-31 03:52:29 +01:00
<?php
final class PhabricatorLogoutController
extends PhabricatorAuthController {
2011-01-31 03:52:29 +01:00
public function shouldRequireLogin() {
return true;
}
public function shouldRequireEmailVerification() {
// Allow unverified users to logout.
return false;
}
public function shouldRequireEnabledUser() {
// Allow disabled users to logout.
return false;
}
2011-01-31 03:52:29 +01:00
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
2011-01-31 03:52:29 +01:00
if ($request->isFormPost()) {
$log = PhabricatorUserLog::initializeNewLog(
$user,
$user->getPHID(),
PhabricatorUserLog::ACTION_LOGOUT);
$log->save();
// 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
// try to login again and tell them to clear any junk.
$phsid = $request->getCookie('phsid');
if ($phsid) {
$user->destroySession($phsid);
}
2011-01-31 03:52:29 +01:00
$request->clearCookie('phsid');
2011-01-31 03:52:29 +01:00
return id(new AphrontRedirectResponse())
->setURI('/login/');
}
if ($user->getPHID()) {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Log out of Phabricator?'))
2013-02-13 23:50:15 +01:00
->appendChild(phutil_tag('p', array(), pht(
'Are you sure you want to log out?')))
->addSubmitButton(pht('Logout'))
->addCancelButton('/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
2011-01-31 03:52:29 +01:00
return id(new AphrontRedirectResponse())->setURI('/');
}
}