1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 23:10:57 +01:00

Allow installs to provide "Request a Username Change" instructions

Summary: Fixes T13420. Allow installs to provide username change instructions if there's someone you should contact to get this done.

Test Plan: {F6885027}

Maniphest Tasks: T13420

Differential Revision: https://secure.phabricator.com/D20828
This commit is contained in:
epriestley 2019-09-24 10:49:53 -07:00
parent 0c331458a8
commit 6af776f84a
3 changed files with 41 additions and 1 deletions

View file

@ -2268,6 +2268,7 @@ phutil_register_library_map(array(
'PhabricatorAuthChallengeStatusController' => 'applications/auth/controller/mfa/PhabricatorAuthChallengeStatusController.php',
'PhabricatorAuthChallengeUpdate' => 'applications/auth/view/PhabricatorAuthChallengeUpdate.php',
'PhabricatorAuthChangePasswordAction' => 'applications/auth/action/PhabricatorAuthChangePasswordAction.php',
'PhabricatorAuthChangeUsernameMessageType' => 'applications/auth/message/PhabricatorAuthChangeUsernameMessageType.php',
'PhabricatorAuthConduitAPIMethod' => 'applications/auth/conduit/PhabricatorAuthConduitAPIMethod.php',
'PhabricatorAuthConduitTokenRevoker' => 'applications/auth/revoker/PhabricatorAuthConduitTokenRevoker.php',
'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php',
@ -8455,6 +8456,7 @@ phutil_register_library_map(array(
'PhabricatorAuthChallengeStatusController' => 'PhabricatorAuthController',
'PhabricatorAuthChallengeUpdate' => 'Phobject',
'PhabricatorAuthChangePasswordAction' => 'PhabricatorSystemAction',
'PhabricatorAuthChangeUsernameMessageType' => 'PhabricatorAuthMessageType',
'PhabricatorAuthConduitAPIMethod' => 'ConduitAPIMethod',
'PhabricatorAuthConduitTokenRevoker' => 'PhabricatorAuthRevoker',
'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController',

View file

@ -0,0 +1,29 @@
<?php
final class PhabricatorAuthChangeUsernameMessageType
extends PhabricatorAuthMessageType {
const MESSAGEKEY = 'user.edit.username';
public function getDisplayName() {
return pht('Username Change Instructions');
}
public function getShortDescription() {
return pht(
'Guidance in the "Change Username" dialog for requesting a '.
'username change.');
}
public function getFullDescription() {
return pht(
'When users click the "Change Username" action on their profile pages '.
'but do not have the required permissions, they will be presented with '.
'a message explaining that they are not authorized to make the edit.'.
"\n\n".
'You can optionally provide additional instructions here to help users '.
'request a username change, if there is someone specific they should '.
'contact or a particular workflow they should use.');
}
}

View file

@ -23,13 +23,22 @@ final class PhabricatorPeopleRenameController
$done_uri = $this->getApplicationURI("manage/{$id}/");
if (!$viewer->getIsAdmin()) {
return $this->newDialog()
$dialog = $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'));
$message_body = PhabricatorAuthMessage::loadMessageText(
$viewer,
PhabricatorAuthChangeUsernameMessageType::MESSAGEKEY);
if (strlen($message_body)) {
$dialog->appendRemarkup($message_body);
}
return $dialog;
}
$validation_exception = null;