[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorAuthTerminateSessionController 4 extends PhabricatorAuthController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 $is_all = ($this->id === 'all'); 17 18 $query = id(new PhabricatorAuthSessionQuery()) 19 ->setViewer($viewer) 20 ->withIdentityPHIDs(array($viewer->getPHID())); 21 if (!$is_all) { 22 $query->withIDs(array($this->id)); 23 } 24 25 $current_key = PhabricatorHash::digest( 26 $request->getCookie(PhabricatorCookies::COOKIE_SESSION)); 27 28 $sessions = $query->execute(); 29 foreach ($sessions as $key => $session) { 30 if ($session->getSessionKey() == $current_key) { 31 // Don't terminate the current login session. 32 unset($sessions[$key]); 33 } 34 } 35 36 $panel_uri = '/settings/panel/sessions/'; 37 38 if (!$sessions) { 39 return $this->newDialog() 40 ->setTitle(pht('No Matching Sessions')) 41 ->appendParagraph( 42 pht('There are no matching sessions to terminate.')) 43 ->appendParagraph( 44 pht( 45 '(You can not terminate your current login session. To '. 46 'terminate it, log out.)')) 47 ->addCancelButton($panel_uri); 48 } 49 50 if ($request->isDialogFormPost()) { 51 foreach ($sessions as $session) { 52 $session->delete(); 53 } 54 return id(new AphrontRedirectResponse())->setURI($panel_uri); 55 } 56 57 if ($is_all) { 58 $title = pht('Terminate Sessions?'); 59 $short = pht('Terminate Sessions'); 60 $body = pht( 61 'Really terminate all sessions? (Your current login session will '. 62 'not be terminated.)'); 63 } else { 64 $title = pht('Terminate Session?'); 65 $short = pht('Terminate Session'); 66 $body = pht( 67 'Really terminate session %s?', 68 phutil_tag('strong', array(), substr($session->getSessionKey(), 0, 6))); 69 } 70 71 return $this->newDialog() 72 ->setTitle($title) 73 ->setShortTitle($short) 74 ->appendParagraph($body) 75 ->addSubmitButton(pht('Terminate')) 76 ->addCancelButton($panel_uri); 77 } 78 79 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |