@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

Clean up redirect URIs for "Temporary Tokens" and "API Tokens" settings panels

Summary: Fixes T11223. I missed a few of these; most of them kept working anyway because we have redirects in place, but make them a bit more modern/not-hard-coded.

Test Plan:
- Generated and revoked API tokens for myself.
- Generated and revoked API tokens for bots.
- Revoked temporary tokens for myself.
- Clicked the link to the API tokens panel from the Conduit console.
- Clicked all the cancel buttons in all the dialogs, too.

In all cases, everything now points at the correct URIs. Previously, some things pointed at the wrong URIs (mostly dealing with stuff for bots).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11223

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

+23 -10
+4 -1
src/applications/auth/controller/PhabricatorAuthRevokeTokenController.php
··· 24 24 } 25 25 } 26 26 27 - $panel_uri = '/settings/panel/tokens/'; 27 + $panel_uri = id(new PhabricatorTokensSettingsPanel()) 28 + ->setViewer($viewer) 29 + ->setUser($viewer) 30 + ->getPanelURI(); 28 31 29 32 if (!$tokens) { 30 33 return $this->newDialog()
+8 -1
src/applications/conduit/controller/PhabricatorConduitController.php
··· 25 25 } 26 26 27 27 protected function renderExampleBox(ConduitAPIMethod $method, $params) { 28 + $viewer = $this->getViewer(); 29 + 28 30 $arc_example = id(new PHUIPropertyListView()) 29 31 ->addRawContent($this->renderExample($method, 'arc', $params)); 30 32 ··· 34 36 $php_example = id(new PHUIPropertyListView()) 35 37 ->addRawContent($this->renderExample($method, 'php', $params)); 36 38 39 + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) 40 + ->setViewer($viewer) 41 + ->setUser($viewer) 42 + ->getPanelURI(); 43 + 37 44 $panel_link = phutil_tag( 38 45 'a', 39 46 array( 40 - 'href' => '/settings/panel/apitokens/', 47 + 'href' => $panel_uri, 41 48 ), 42 49 pht('Conduit API Tokens')); 43 50
+4 -5
src/applications/conduit/controller/PhabricatorConduitTokenEditController.php
··· 49 49 $submit_button = pht('Generate Token'); 50 50 } 51 51 52 - if ($viewer->getPHID() == $object->getPHID()) { 53 - $panel_uri = '/settings/panel/apitokens/'; 54 - } else { 55 - $panel_uri = '/settings/'.$object->getID().'/panel/apitokens/'; 56 - } 52 + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) 53 + ->setViewer($viewer) 54 + ->setUser($object) 55 + ->getPanelURI(); 57 56 58 57 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 59 58 $viewer,
+7 -3
src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php
··· 31 31 'Really terminate this token? Any system using this token '. 32 32 'will no longer be able to make API requests.'); 33 33 $submit_button = pht('Terminate Token'); 34 - $panel_uri = '/settings/panel/apitokens/'; 35 34 } else { 36 35 $tokens = id(new PhabricatorConduitTokenQuery()) 37 36 ->setViewer($viewer) ··· 51 50 $submit_button = pht('Terminate Tokens'); 52 51 } 53 52 54 - $panel_uri = '/settings/panel/apitokens/'; 55 53 if ($object_phid != $viewer->getPHID()) { 56 54 $object = id(new PhabricatorObjectQuery()) 57 55 ->setViewer($viewer) ··· 60 58 if (!$object) { 61 59 return new Aphront404Response(); 62 60 } 63 - $panel_uri = '/settings/'.$object->getID().'/panel/apitokens/'; 61 + } else { 62 + $object = $viewer; 64 63 } 64 + 65 + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) 66 + ->setViewer($viewer) 67 + ->setUser($object) 68 + ->getPanelURI(); 65 69 66 70 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 67 71 $viewer,