mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
36103dfa18
Summary: Updates Auth app for handleRequest Test Plan: Tested what I could, Log in, Log out, Change Password, New account, Verify account... but extra eyes very helpful here. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8628 Differential Revision: https://secure.phabricator.com/D13748
72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class PhabricatorLogoutController
|
|
extends PhabricatorAuthController {
|
|
|
|
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;
|
|
}
|
|
|
|
public function shouldAllowPartialSessions() {
|
|
return true;
|
|
}
|
|
|
|
public function shouldAllowLegallyNonCompliantUsers() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $this->getViewer();
|
|
|
|
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
|
|
// 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(PhabricatorCookies::COOKIE_SESSION);
|
|
if (strlen($phsid)) {
|
|
$session = id(new PhabricatorAuthSessionQuery())
|
|
->setViewer($viewer)
|
|
->withSessionKeys(array($phsid))
|
|
->executeOne();
|
|
if ($session) {
|
|
$session->delete();
|
|
}
|
|
}
|
|
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI('/auth/loggedout/');
|
|
}
|
|
|
|
if ($viewer->getPHID()) {
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($viewer)
|
|
->setTitle(pht('Log out of Phabricator?'))
|
|
->appendChild(pht('Are you sure you want to log out?'))
|
|
->addSubmitButton(pht('Logout'))
|
|
->addCancelButton('/');
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
return id(new AphrontRedirectResponse())->setURI('/');
|
|
}
|
|
|
|
}
|