1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Update DarkConsole for handleRequest

Summary: Ref T8628

Test Plan: Updated DarkConsoleDataController and observed that the darkconsole still works as expected

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley, yelirekim

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D16570
This commit is contained in:
Josh Cox 2016-09-15 20:40:46 -04:00
parent dda06c6bdc
commit 2e4b5b45a2

View file

@ -2,8 +2,6 @@
final class DarkConsoleDataController extends PhabricatorController { final class DarkConsoleDataController extends PhabricatorController {
private $key;
public function shouldRequireLogin() { public function shouldRequireLogin() {
return !PhabricatorEnv::getEnvConfig('darkconsole.always-on'); return !PhabricatorEnv::getEnvConfig('darkconsole.always-on');
} }
@ -16,19 +14,15 @@ final class DarkConsoleDataController extends PhabricatorController {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->key = $data['key']; $viewer = $request->getViewer();
} $key = $request->getURIData('key');
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$cache = new PhabricatorKeyValueDatabaseCache(); $cache = new PhabricatorKeyValueDatabaseCache();
$cache = new PhutilKeyValueCacheProfiler($cache); $cache = new PhutilKeyValueCacheProfiler($cache);
$cache->setProfiler(PhutilServiceProfiler::getInstance()); $cache->setProfiler(PhutilServiceProfiler::getInstance());
$result = $cache->getKey('darkconsole:'.$this->key); $result = $cache->getKey('darkconsole:'.$key);
if (!$result) { if (!$result) {
return new Aphront400Response(); return new Aphront400Response();
} }
@ -43,7 +37,7 @@ final class DarkConsoleDataController extends PhabricatorController {
return new Aphront400Response(); return new Aphront400Response();
} }
if ($result['user'] != $user->getPHID()) { if ($result['user'] != $viewer->getPHID()) {
return new Aphront400Response(); return new Aphront400Response();
} }