From 0c331458a88ba991b8c66d45c29cfcec8f5fe505 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 24 Sep 2019 10:40:12 -0700 Subject: [PATCH] When non-administrators click "Change Username", explain why they can't continue Summary: Ref T13420. This workflow currently dead-ends for non-administrators. Instead, provide explanatory text. Test Plan: - Clicked "Change Username" as an administrator, same workflow as always. - Clicked "Change Username" as a non-administrator, got explanatory text. Maniphest Tasks: T13420 Differential Revision: https://secure.phabricator.com/D20827 --- .../PhabricatorPeopleRenameController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/applications/people/controller/PhabricatorPeopleRenameController.php b/src/applications/people/controller/PhabricatorPeopleRenameController.php index 9f0c2b21a8..2ee40863bb 100644 --- a/src/applications/people/controller/PhabricatorPeopleRenameController.php +++ b/src/applications/people/controller/PhabricatorPeopleRenameController.php @@ -3,8 +3,13 @@ final class PhabricatorPeopleRenameController extends PhabricatorPeopleController { + public function shouldRequireAdmin() { + return false; + } + public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); + $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) @@ -17,6 +22,16 @@ final class PhabricatorPeopleRenameController $done_uri = $this->getApplicationURI("manage/{$id}/"); + if (!$viewer->getIsAdmin()) { + return $this->newDialog() + ->setTitle(pht('Change Username')) + ->appendParagraph( + pht( + 'You can not change usernames because you are not an '. + 'administrator. Only administrators can change usernames.')) + ->addCancelButton($done_uri, pht('Okay')); + } + $validation_exception = null; $username = $user->getUsername(); if ($request->isFormOrHisecPost()) {