mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Centralize "this is the current user for the request" code
Summary: Ref T11098. This primarily fixes Conduit calls to `*.edit` methods failing when trying to access user preferences. (The actual access is a little weird, since it seems like we're building some UI stuff inside a policy query, but that's an issue for another time.) To fix this, consolidate the "we're about to run some kind of request with this user" code and run it consistently for web, conduit, and SSH sessions. Additionally, make sure we swap things to the user's translation. Test Plan: - Ran `maniphest.edit` via `arc call-conduit`, no more settings exception. - Set translation to ALL CAPS, got all caps output from `ssh` and Conduit. Reviewers: avivey, chad Reviewed By: chad Maniphest Tasks: T11098 Differential Revision: https://secure.phabricator.com/D16066
This commit is contained in:
parent
8a7ded6129
commit
814fa135b0
4 changed files with 17 additions and 2 deletions
|
@ -103,6 +103,9 @@ try {
|
|||
'Invalid username ("%s"). There is no user with this username.',
|
||||
$user_name));
|
||||
}
|
||||
|
||||
id(new PhabricatorAuthSessionEngine())
|
||||
->willServeRequestForUser($user);
|
||||
} else if (strlen($device_name)) {
|
||||
if (!$remote_address) {
|
||||
throw new Exception(
|
||||
|
|
|
@ -164,7 +164,6 @@ final class PhabricatorAuthSessionEngine extends Phobject {
|
|||
|
||||
$cache_raw = $this->filterRawCacheData($user, $types_map, $cache_raw);
|
||||
$user->attachRawCacheData($cache_raw);
|
||||
$user->setAllowInlineCacheGeneration(true);
|
||||
|
||||
switch ($session_type) {
|
||||
case PhabricatorAuthSession::TYPE_WEB:
|
||||
|
@ -832,4 +831,12 @@ final class PhabricatorAuthSessionEngine extends Phobject {
|
|||
return $cache_raw;
|
||||
}
|
||||
|
||||
public function willServeRequestForUser(PhabricatorUser $user) {
|
||||
// We allow the login user to generate any missing cache data inline.
|
||||
$user->setAllowInlineCacheGeneration(true);
|
||||
|
||||
// Switch to the user's translation.
|
||||
PhabricatorEnv::setLocaleCode($user->getTranslation());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ abstract class PhabricatorController extends AphrontController {
|
|||
$request->setUser($user);
|
||||
}
|
||||
|
||||
PhabricatorEnv::setLocaleCode($user->getTranslation());
|
||||
id(new PhabricatorAuthSessionEngine())
|
||||
->willServeRequestForUser($user);
|
||||
|
||||
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
|
||||
$dark_console = PhabricatorDarkConsoleSetting::SETTINGKEY;
|
||||
|
|
|
@ -487,6 +487,10 @@ final class PhabricatorConduitAPIController
|
|||
}
|
||||
|
||||
$request->setUser($user);
|
||||
|
||||
id(new PhabricatorAuthSessionEngine())
|
||||
->willServeRequestForUser($user);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue