Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/conduit/PhabricatorAuthLogoutConduitAPIMethod.php
12256 views
1
<?php
2
3
final class PhabricatorAuthLogoutConduitAPIMethod
4
extends PhabricatorAuthConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'auth.logout';
8
}
9
10
public function getMethodSummary() {
11
return pht('Terminate all login sessions.');
12
}
13
14
public function getMethodDescription() {
15
return pht(
16
'Terminate all web login sessions. If called via OAuth, also terminate '.
17
'the current OAuth token.'.
18
"\n\n".
19
'WARNING: This method does what it claims on the label. If you call '.
20
'this method via the test console in the web UI, it will log you out!');
21
}
22
23
protected function defineParamTypes() {
24
return array();
25
}
26
27
protected function defineReturnType() {
28
return 'void';
29
}
30
31
public function getRequiredScope() {
32
return self::SCOPE_ALWAYS;
33
}
34
35
protected function execute(ConduitAPIRequest $request) {
36
$viewer = $request->getUser();
37
38
// Destroy all web sessions.
39
$engine = id(new PhabricatorAuthSessionEngine());
40
$engine->terminateLoginSessions($viewer);
41
42
// If we were called via OAuth, destroy the OAuth token.
43
$oauth_token = $request->getOAuthToken();
44
if ($oauth_token) {
45
$oauth_token->delete();
46
}
47
48
return null;
49
}
50
51
}
52
53