From ec8581ab629e970aef58d7b7fe44e1d1dd3fe2c8 Mon Sep 17 00:00:00 2001 From: epriestley <git@epriestley.com> Date: Tue, 28 Jun 2016 14:22:31 -0700 Subject: [PATCH] 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 --- .../PhabricatorAuthRevokeTokenController.php | 5 ++++- .../controller/PhabricatorConduitController.php | 9 ++++++++- .../PhabricatorConduitTokenEditController.php | 9 ++++----- .../PhabricatorConduitTokenTerminateController.php | 10 +++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/applications/auth/controller/PhabricatorAuthRevokeTokenController.php b/src/applications/auth/controller/PhabricatorAuthRevokeTokenController.php index 6d516916eb..8e063ba565 100644 --- a/src/applications/auth/controller/PhabricatorAuthRevokeTokenController.php +++ b/src/applications/auth/controller/PhabricatorAuthRevokeTokenController.php @@ -24,7 +24,10 @@ final class PhabricatorAuthRevokeTokenController } } - $panel_uri = '/settings/panel/tokens/'; + $panel_uri = id(new PhabricatorTokensSettingsPanel()) + ->setViewer($viewer) + ->setUser($viewer) + ->getPanelURI(); if (!$tokens) { return $this->newDialog() diff --git a/src/applications/conduit/controller/PhabricatorConduitController.php b/src/applications/conduit/controller/PhabricatorConduitController.php index 000d01f888..b29c05f2af 100644 --- a/src/applications/conduit/controller/PhabricatorConduitController.php +++ b/src/applications/conduit/controller/PhabricatorConduitController.php @@ -25,6 +25,8 @@ abstract class PhabricatorConduitController extends PhabricatorController { } protected function renderExampleBox(ConduitAPIMethod $method, $params) { + $viewer = $this->getViewer(); + $arc_example = id(new PHUIPropertyListView()) ->addRawContent($this->renderExample($method, 'arc', $params)); @@ -34,10 +36,15 @@ abstract class PhabricatorConduitController extends PhabricatorController { $php_example = id(new PHUIPropertyListView()) ->addRawContent($this->renderExample($method, 'php', $params)); + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) + ->setViewer($viewer) + ->setUser($viewer) + ->getPanelURI(); + $panel_link = phutil_tag( 'a', array( - 'href' => '/settings/panel/apitokens/', + 'href' => $panel_uri, ), pht('Conduit API Tokens')); diff --git a/src/applications/conduit/controller/PhabricatorConduitTokenEditController.php b/src/applications/conduit/controller/PhabricatorConduitTokenEditController.php index 503456d010..7550f92210 100644 --- a/src/applications/conduit/controller/PhabricatorConduitTokenEditController.php +++ b/src/applications/conduit/controller/PhabricatorConduitTokenEditController.php @@ -49,11 +49,10 @@ final class PhabricatorConduitTokenEditController $submit_button = pht('Generate Token'); } - if ($viewer->getPHID() == $object->getPHID()) { - $panel_uri = '/settings/panel/apitokens/'; - } else { - $panel_uri = '/settings/'.$object->getID().'/panel/apitokens/'; - } + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) + ->setViewer($viewer) + ->setUser($object) + ->getPanelURI(); id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( $viewer, diff --git a/src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php b/src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php index 466089ebeb..9f1ffd2964 100644 --- a/src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php +++ b/src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php @@ -31,7 +31,6 @@ final class PhabricatorConduitTokenTerminateController 'Really terminate this token? Any system using this token '. 'will no longer be able to make API requests.'); $submit_button = pht('Terminate Token'); - $panel_uri = '/settings/panel/apitokens/'; } else { $tokens = id(new PhabricatorConduitTokenQuery()) ->setViewer($viewer) @@ -51,7 +50,6 @@ final class PhabricatorConduitTokenTerminateController $submit_button = pht('Terminate Tokens'); } - $panel_uri = '/settings/panel/apitokens/'; if ($object_phid != $viewer->getPHID()) { $object = id(new PhabricatorObjectQuery()) ->setViewer($viewer) @@ -60,9 +58,15 @@ final class PhabricatorConduitTokenTerminateController if (!$object) { return new Aphront404Response(); } - $panel_uri = '/settings/'.$object->getID().'/panel/apitokens/'; + } else { + $object = $viewer; } + $panel_uri = id(new PhabricatorConduitTokensSettingsPanel()) + ->setViewer($viewer) + ->setUser($object) + ->getPanelURI(); + id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( $viewer, $request,