Path: blob/master/src/applications/auth/controller/mfa/PhabricatorAuthFactorProviderMessageController.php
12262 views
<?php12final class PhabricatorAuthFactorProviderMessageController3extends PhabricatorAuthFactorProviderController {45public function handleRequest(AphrontRequest $request) {6$this->requireApplicationCapability(7AuthManageProvidersCapability::CAPABILITY);89$viewer = $request->getViewer();10$id = $request->getURIData('id');1112$provider = id(new PhabricatorAuthFactorProviderQuery())13->setViewer($viewer)14->withIDs(array($id))15->requireCapabilities(16array(17PhabricatorPolicyCapability::CAN_VIEW,18PhabricatorPolicyCapability::CAN_EDIT,19))20->executeOne();21if (!$provider) {22return new Aphront404Response();23}2425$cancel_uri = $provider->getURI();26$enroll_key =27PhabricatorAuthFactorProviderEnrollMessageTransaction::TRANSACTIONTYPE;2829$message = $provider->getEnrollMessage();3031if ($request->isFormOrHisecPost()) {32$message = $request->getStr('message');3334$xactions = array();3536$xactions[] = id(new PhabricatorAuthFactorProviderTransaction())37->setTransactionType($enroll_key)38->setNewValue($message);3940$editor = id(new PhabricatorAuthFactorProviderEditor())41->setActor($viewer)42->setContentSourceFromRequest($request)43->setContinueOnNoEffect(true)44->setContinueOnMissingFields(true)45->setCancelURI($cancel_uri);4647$editor->applyTransactions($provider, $xactions);4849return id(new AphrontRedirectResponse())->setURI($cancel_uri);50}5152$default_message = $provider->getEnrollDescription($viewer);53$default_message = new PHUIRemarkupView($viewer, $default_message);5455$form = id(new AphrontFormView())56->setViewer($viewer)57->appendRemarkupInstructions(58pht(59'When users add a factor for this provider, they are given this '.60'enrollment guidance by default:'))61->appendControl(62id(new AphrontFormMarkupControl())63->setLabel(pht('Default Message'))64->setValue($default_message))65->appendRemarkupInstructions(66pht(67'You may optionally customize the enrollment message users are '.68'presented with by providing a replacement message below:'))69->appendControl(70id(new PhabricatorRemarkupControl())71->setLabel(pht('Custom Message'))72->setName('message')73->setValue($message));7475return $this->newDialog()76->setTitle(pht('Change Enroll Message'))77->setWidth(AphrontDialogView::WIDTH_FORM)78->appendForm($form)79->addCancelButton($cancel_uri)80->addSubmitButton(pht('Save'));81}8283}848586