3 final class PhabricatorSessionsSettingsPanel
extends PhabricatorSettingsPanel
{
5 public function getPanelKey() {
9 public function getPanelName() {
10 return pht('Sessions');
13 public function getPanelMenuIcon() {
17 public function getPanelGroupKey() {
18 return PhabricatorSettingsLogsPanelGroup
::PANELGROUPKEY
;
21 public function isEnabled() {
25 public function processRequest(AphrontRequest
$request) {
26 $viewer = $request->getUser();
28 $accounts = id(new PhabricatorExternalAccountQuery())
30 ->withUserPHIDs(array($viewer->getPHID()))
31 ->requireCapabilities(
33 PhabricatorPolicyCapability
::CAN_VIEW
,
34 PhabricatorPolicyCapability
::CAN_EDIT
,
38 $identity_phids = mpull($accounts, 'getPHID');
39 $identity_phids[] = $viewer->getPHID();
41 $sessions = id(new PhabricatorAuthSessionQuery())
43 ->withIdentityPHIDs($identity_phids)
46 $handles = id(new PhabricatorHandleQuery())
48 ->withPHIDs($identity_phids)
51 $current_key = PhabricatorAuthSession
::newSessionDigest(
52 new PhutilOpaqueEnvelope(
53 $request->getCookie(PhabricatorCookies
::COOKIE_SESSION
)));
57 foreach ($sessions as $session) {
58 $is_current = phutil_hashes_are_identical(
59 $session->getSessionKey(),
62 $rowc[] = 'highlighted';
66 'class' => 'small button button-grey disabled',
71 $button = javelin_tag(
74 'href' => '/auth/session/terminate/'.$session->getID().'/',
75 'class' => 'small button button-grey',
76 'sigil' => 'workflow',
81 $hisec = ($session->getHighSecurityUntil() - time());
84 $handles[$session->getUserPHID()]->renderLink(),
85 substr($session->getSessionKey(), 0, 6),
88 ?
phutil_format_relative_time($hisec)
90 phabricator_datetime($session->getSessionStart(), $viewer),
91 phabricator_date($session->getSessionExpires(), $viewer),
96 $table = new AphrontTableView($rows);
97 $table->setNoDataString(pht("You don't have any active sessions."));
98 $table->setRowClasses($rowc);
109 $table->setColumnClasses(
121 $buttons[] = id(new PHUIButtonView())
123 ->setIcon('fa-warning')
124 ->setText(pht('Terminate All Sessions'))
125 ->setHref('/auth/session/terminate/all/')
127 ->setColor(PHUIButtonView
::RED
);
129 $hisec = ($viewer->getSession()->getHighSecurityUntil() - time());
131 $buttons[] = id(new PHUIButtonView())
134 ->setText(pht('Leave High Security'))
135 ->setHref('/auth/session/downgrade/')
137 ->setColor(PHUIButtonView
::RED
);
140 return $this->newBox(pht('Active Login Sessions'), $table, $buttons);