@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace "web" and "conduit" magic session strings with constants

Summary: Ref T4310. Ref T3720. We use bare strings to refer to session types in several places right now; use constants instead.

Test Plan: grep; logged out; logged in; ran Conduit commands.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4310, T3720

Differential Revision: https://secure.phabricator.com/D7963

+14 -8
+1 -1
src/applications/auth/controller/PhabricatorAuthController.php
··· 65 65 protected function loginUser(PhabricatorUser $user) { 66 66 67 67 $response = $this->buildLoginValidateResponse($user); 68 - $session_type = 'web'; 68 + $session_type = PhabricatorAuthSession::TYPE_WEB; 69 69 70 70 $event_type = PhabricatorEventType::TYPE_AUTH_WILLLOGINUSER; 71 71 $event_data = array(
+4 -3
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
··· 36 36 * You can configure the maximum number of concurrent sessions for various 37 37 * session types in the Phabricator configuration. 38 38 * 39 - * @param string Session type, like "web". 39 + * @param const Session type constant (see 40 + * @{class:PhabricatorAuthSession}). 40 41 * @param phid Identity to establish a session for, usually a user PHID. 41 42 * @return string Newly generated session key. 42 43 */ ··· 56 57 57 58 $session_limit = 1; 58 59 switch ($session_type) { 59 - case 'web': 60 + case PhabricatorAuthSession::TYPE_WEB: 60 61 $session_limit = PhabricatorEnv::getEnvConfig('auth.sessions.web'); 61 62 break; 62 - case 'conduit': 63 + case PhabricatorAuthSession::TYPE_CONDUIT: 63 64 $session_limit = PhabricatorEnv::getEnvConfig('auth.sessions.conduit'); 64 65 break; 65 66 default:
+3
src/applications/auth/storage/PhabricatorAuthSession.php
··· 3 3 final class PhabricatorAuthSession extends PhabricatorAuthDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 + const TYPE_WEB = 'web'; 7 + const TYPE_CONDUIT = 'conduit'; 8 + 6 9 protected $userPHID; 7 10 protected $type; 8 11 protected $sessionKey;
+1 -1
src/applications/base/controller/PhabricatorController.php
··· 38 38 $phsid = $request->getCookie('phsid'); 39 39 if ($phsid) { 40 40 $session_user = id(new PhabricatorAuthSessionEngine()) 41 - ->loadUserForSession('web', $phsid); 41 + ->loadUserForSession(PhabricatorAuthSession::TYPE_WEB, $phsid); 42 42 if ($session_user) { 43 43 $user = $session_user; 44 44 }
+1 -1
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 280 280 } 281 281 282 282 $user = id(new PhabricatorAuthSessionEngine()) 283 - ->loadUserForSession('conduit', $session_key); 283 + ->loadUserForSession(PhabricatorAuthSession::TYPE_CONDUIT, $session_key); 284 284 285 285 if (!$user) { 286 286 return array(
+3 -1
src/applications/conduit/method/ConduitAPI_conduit_connect_Method.php
··· 143 143 throw new ConduitException('ERR-INVALID-CERTIFICATE'); 144 144 } 145 145 $session_key = id(new PhabricatorAuthSessionEngine()) 146 - ->establishSession('conduit', $user->getPHID()); 146 + ->establishSession( 147 + PhabricatorAuthSession::TYPE_CONDUIT, 148 + $user->getPHID()); 147 149 } else { 148 150 throw new ConduitException('ERR-NO-CERTIFICATE'); 149 151 }
+1 -1
src/applications/settings/panel/PhabricatorSettingsPanelConduit.php
··· 37 37 $sessions = id(new PhabricatorAuthSessionQuery()) 38 38 ->setViewer($user) 39 39 ->withIdentityPHIDs(array($user->getPHID())) 40 - ->withSessionTypes(array('conduit')) 40 + ->withSessionTypes(array(PhabricatorAuthSession::TYPE_CONDUIT)) 41 41 ->execute(); 42 42 foreach ($sessions as $session) { 43 43 $session->delete();