Differential D20036 Diff 47865 src/applications/people/controller/PhabricatorPeopleRenameController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleRenameController.php
Show All 11 Lines | $user = id(new PhabricatorPeopleQuery()) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$user) { | if (!$user) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$done_uri = $this->getApplicationURI("manage/{$id}/"); | $done_uri = $this->getApplicationURI("manage/{$id}/"); | ||||
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( | |||||
$viewer, | |||||
$request, | |||||
$done_uri); | |||||
$validation_exception = null; | $validation_exception = null; | ||||
$username = $user->getUsername(); | $username = $user->getUsername(); | ||||
if ($request->isFormPost()) { | if ($request->isFormOrHisecPost()) { | ||||
$username = $request->getStr('username'); | $username = $request->getStr('username'); | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhabricatorUserTransaction()) | $xactions[] = id(new PhabricatorUserTransaction()) | ||||
->setTransactionType( | ->setTransactionType( | ||||
PhabricatorUserUsernameTransaction::TRANSACTIONTYPE) | PhabricatorUserUsernameTransaction::TRANSACTIONTYPE) | ||||
->setNewValue($username); | ->setNewValue($username); | ||||
$editor = id(new PhabricatorUserTransactionEditor()) | $editor = id(new PhabricatorUserTransactionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->setCancelURI($done_uri) | |||||
->setContinueOnMissingFields(true); | ->setContinueOnMissingFields(true); | ||||
try { | try { | ||||
$editor->applyTransactions($user, $xactions); | $editor->applyTransactions($user, $xactions); | ||||
return id(new AphrontRedirectResponse())->setURI($done_uri); | return id(new AphrontRedirectResponse())->setURI($done_uri); | ||||
} catch (PhabricatorApplicationTransactionValidationException $ex) { | } catch (PhabricatorApplicationTransactionValidationException $ex) { | ||||
$validation_exception = $ex; | $validation_exception = $ex; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |