Path: blob/master/src/applications/passphrase/controller/PassphraseCredentialDestroyController.php
12262 views
<?php12final class PassphraseCredentialDestroyController3extends 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 ($request->isFormPost()) {3132$xactions = array();33$xactions[] = id(new PassphraseCredentialTransaction())34->setTransactionType(35PassphraseCredentialDestroyTransaction::TRANSACTIONTYPE)36->setNewValue(1);3738$editor = id(new PassphraseCredentialTransactionEditor())39->setActor($viewer)40->setContinueOnMissingFields(true)41->setContentSourceFromRequest($request)42->applyTransactions($credential, $xactions);4344return id(new AphrontRedirectResponse())->setURI($view_uri);45}4647return $this->newDialog()48->setUser($viewer)49->setTitle(pht('Really destroy credential?'))50->appendChild(51pht(52'This credential will be deactivated and the secret will be '.53'unrecoverably destroyed. Anything relying on this credential '.54'will cease to function. This operation can not be undone.'))55->addSubmitButton(pht('Destroy Credential'))56->addCancelButton($view_uri);57}5859}606162