Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F569557
PhabricatorAuthTerminateSessionController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorAuthTerminateSessionController.php
View Options
<?php
final
class
PhabricatorAuthTerminateSessionController
extends
PhabricatorAuthController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$is_all
=
(
$id
===
'all'
);
$query
=
id
(
new
PhabricatorAuthSessionQuery
())
->
setViewer
(
$viewer
)
->
withIdentityPHIDs
(
array
(
$viewer
->
getPHID
()));
if
(!
$is_all
)
{
$query
->
withIDs
(
array
(
$id
));
}
$current_key
=
PhabricatorAuthSession
::
newSessionDigest
(
new
PhutilOpaqueEnvelope
(
$request
->
getCookie
(
PhabricatorCookies
::
COOKIE_SESSION
)));
$sessions
=
$query
->
execute
();
foreach
(
$sessions
as
$key
=>
$session
)
{
$is_current
=
phutil_hashes_are_identical
(
$session
->
getSessionKey
(),
$current_key
);
if
(
$is_current
)
{
// Don't terminate the current login session.
unset
(
$sessions
[
$key
]);
}
}
$panel_uri
=
'/settings/panel/sessions/'
;
if
(!
$sessions
)
{
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'No Matching Sessions'
))
->
appendParagraph
(
pht
(
'There are no matching sessions to terminate.'
))
->
appendParagraph
(
pht
(
'(You can not terminate your current login session. To '
.
'terminate it, log out.)'
))
->
addCancelButton
(
$panel_uri
);
}
if
(
$request
->
isDialogFormPost
())
{
foreach
(
$sessions
as
$session
)
{
$session
->
delete
();
}
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$panel_uri
);
}
if
(
$is_all
)
{
$title
=
pht
(
'Terminate Sessions?'
);
$short
=
pht
(
'Terminate Sessions'
);
$body
=
pht
(
'Really terminate all sessions? (Your current login session will '
.
'not be terminated.)'
);
}
else
{
$title
=
pht
(
'Terminate Session?'
);
$short
=
pht
(
'Terminate Session'
);
$body
=
pht
(
'Really terminate session %s?'
,
phutil_tag
(
'strong'
,
array
(),
substr
(
$session
->
getSessionKey
(),
0
,
6
)));
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
setShortTitle
(
$short
)
->
appendParagraph
(
$body
)
->
addSubmitButton
(
pht
(
'Terminate'
))
->
addCancelButton
(
$panel_uri
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 13, 2:49 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108837
Default Alt Text
PhabricatorAuthTerminateSessionController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment