Path: blob/master/src/applications/passphrase/controller/PassphraseCredentialLockController.php
12256 views
<?php12final class PassphraseCredentialLockController3extends PassphraseController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();7$id = $request->getURIData('id');89$credential = id(new PassphraseCredentialQuery())10->setViewer($viewer)11->withIDs(array($id))12->requireCapabilities(13array(14PhabricatorPolicyCapability::CAN_VIEW,15PhabricatorPolicyCapability::CAN_EDIT,16))17->executeOne();18if (!$credential) {19return new Aphront404Response();20}2122$type = PassphraseCredentialType::getTypeByConstant(23$credential->getCredentialType());24if (!$type) {25throw new Exception(pht('Credential has invalid type "%s"!', $type));26}2728$view_uri = '/K'.$credential->getID();2930if ($credential->getIsLocked()) {31return $this->newDialog()32->setTitle(pht('Credential Already Locked'))33->appendChild(34pht('This credential is already locked.'))35->addCancelButton($view_uri, pht('Close'));36}3738if ($request->isFormPost()) {39$xactions = array();4041$xactions[] = id(new PassphraseCredentialTransaction())42->setTransactionType(43PassphraseCredentialConduitTransaction::TRANSACTIONTYPE)44->setNewValue(0);4546$xactions[] = id(new PassphraseCredentialTransaction())47->setTransactionType(48PassphraseCredentialLockTransaction::TRANSACTIONTYPE)49->setNewValue(1);5051$editor = id(new PassphraseCredentialTransactionEditor())52->setActor($viewer)53->setContinueOnMissingFields(true)54->setContinueOnNoEffect(true)55->setContentSourceFromRequest($request)56->applyTransactions($credential, $xactions);5758return id(new AphrontRedirectResponse())->setURI($view_uri);59}6061return $this->newDialog()62->setTitle(pht('Lock Credential'))63->appendChild(64pht(65'This credential will be locked and the secret will be hidden '.66'forever. If Conduit access is enabled, it will be revoked. '.67'Anything relying on this credential will still function. This '.68'operation can not be undone.'))69->addSubmitButton(pht('Lock Credential'))70->addCancelButton($view_uri);71}7273}747576