[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/auth/controller/ -> PhabricatorLogoutController.php (source)

   1  <?php
   2  
   3  final class PhabricatorLogoutController
   4    extends PhabricatorAuthController {
   5  
   6    public function shouldRequireLogin() {
   7      return true;
   8    }
   9  
  10    public function shouldRequireEmailVerification() {
  11      // Allow unverified users to logout.
  12      return false;
  13    }
  14  
  15    public function shouldRequireEnabledUser() {
  16      // Allow disabled users to logout.
  17      return false;
  18    }
  19  
  20    public function shouldAllowPartialSessions() {
  21      return true;
  22    }
  23  
  24    public function processRequest() {
  25      $request = $this->getRequest();
  26      $user = $request->getUser();
  27  
  28      if ($request->isFormPost()) {
  29  
  30        $log = PhabricatorUserLog::initializeNewLog(
  31          $user,
  32          $user->getPHID(),
  33          PhabricatorUserLog::ACTION_LOGOUT);
  34        $log->save();
  35  
  36        // Destroy the user's session in the database so logout works even if
  37        // their cookies have some issues. We'll detect cookie issues when they
  38        // try to login again and tell them to clear any junk.
  39        $phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
  40        if (strlen($phsid)) {
  41          $session = id(new PhabricatorAuthSessionQuery())
  42            ->setViewer($user)
  43            ->withSessionKeys(array($phsid))
  44            ->executeOne();
  45          if ($session) {
  46            $session->delete();
  47          }
  48        }
  49        $request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
  50  
  51        return id(new AphrontRedirectResponse())
  52          ->setURI('/login/');
  53      }
  54  
  55      if ($user->getPHID()) {
  56        $dialog = id(new AphrontDialogView())
  57          ->setUser($user)
  58          ->setTitle(pht('Log out of Phabricator?'))
  59          ->appendChild(pht('Are you sure you want to log out?'))
  60          ->addSubmitButton(pht('Logout'))
  61          ->addCancelButton('/');
  62  
  63        return id(new AphrontDialogResponse())->setDialog($dialog);
  64      }
  65  
  66      return id(new AphrontRedirectResponse())->setURI('/');
  67    }
  68  
  69  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1