mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Update accountadmin to use new admin empowerment code
Summary: Fixes https://discourse.phabricator-community.org/t/admin-account-creation-fails-call-to-undefined-method-phabricatorusereditor-makeadminuser/2227. This callsite got skipped when updating the EmpowerController to use the new transactional admin approval code. Test Plan: Invoked `accountadmin` to promote a user, no longer got an exception. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D19915
This commit is contained in:
parent
aa3b2ec5dc
commit
979187132d
3 changed files with 44 additions and 3 deletions
|
@ -200,9 +200,28 @@ $user->openTransaction();
|
|||
$editor->updateUser($user, $verify_email);
|
||||
}
|
||||
|
||||
$editor->makeAdminUser($user, $set_admin);
|
||||
$editor->makeSystemAgentUser($user, $set_system_agent);
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhabricatorUserTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($set_admin);
|
||||
|
||||
$actor = PhabricatorUser::getOmnipotentUser();
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorConsoleContentSource::SOURCECONST);
|
||||
|
||||
$people_application_phid = id(new PhabricatorPeopleApplication())->getPHID();
|
||||
|
||||
$transaction_editor = id(new PhabricatorUserTransactionEditor())
|
||||
->setActor($actor)
|
||||
->setActingAsPHID($people_application_phid)
|
||||
->setContentSource($content_source)
|
||||
->setContinueOnMissingFields(true);
|
||||
|
||||
$transaction_editor->applyTransactions($user, $xactions);
|
||||
|
||||
$user->saveTransaction();
|
||||
|
||||
echo pht('Saved changes.')."\n";
|
||||
|
|
|
@ -416,7 +416,26 @@ final class PhabricatorAuthRegisterController
|
|||
}
|
||||
|
||||
if ($is_setup) {
|
||||
$editor->makeAdminUser($user, true);
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhabricatorUserTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue(true);
|
||||
|
||||
$actor = PhabricatorUser::getOmnipotentUser();
|
||||
$content_source = PhabricatorContentSource::newFromRequest(
|
||||
$request);
|
||||
|
||||
$people_application_phid = id(new PhabricatorPeopleApplication())
|
||||
->getPHID();
|
||||
|
||||
$transaction_editor = id(new PhabricatorUserTransactionEditor())
|
||||
->setActor($actor)
|
||||
->setActingAsPHID($people_application_phid)
|
||||
->setContentSource($content_source)
|
||||
->setContinueOnMissingFields(true);
|
||||
|
||||
$transaction_editor->applyTransactions($user, $xactions);
|
||||
}
|
||||
|
||||
$account->setUserPHID($user->getPHID());
|
||||
|
|
|
@ -45,7 +45,10 @@ final class PhabricatorUserEmpowerTransaction
|
|||
'status as an administrator.'), $xaction);
|
||||
}
|
||||
|
||||
if (!$actor->getIsAdmin()) {
|
||||
$is_admin = $actor->getIsAdmin();
|
||||
$is_omnipotent = $actor->isOmnipotent();
|
||||
|
||||
if (!$is_admin && !$is_omnipotent) {
|
||||
$errors[] = $this->newInvalidError(
|
||||
pht('You must be an administrator to create administrators.'),
|
||||
$xaction);
|
||||
|
|
Loading…
Reference in a new issue