Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/passphrase/controller/PassphraseCredentialDestroyController.php
12262 views
1
<?php
2
3
final class PassphraseCredentialDestroyController
4
extends PassphraseController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
$id = $request->getURIData('id');
9
10
$credential = id(new PassphraseCredentialQuery())
11
->setViewer($viewer)
12
->withIDs(array($id))
13
->requireCapabilities(
14
array(
15
PhabricatorPolicyCapability::CAN_VIEW,
16
PhabricatorPolicyCapability::CAN_EDIT,
17
))
18
->executeOne();
19
if (!$credential) {
20
return new Aphront404Response();
21
}
22
23
$type = PassphraseCredentialType::getTypeByConstant(
24
$credential->getCredentialType());
25
if (!$type) {
26
throw new Exception(pht('Credential has invalid type "%s"!', $type));
27
}
28
29
$view_uri = '/K'.$credential->getID();
30
31
if ($request->isFormPost()) {
32
33
$xactions = array();
34
$xactions[] = id(new PassphraseCredentialTransaction())
35
->setTransactionType(
36
PassphraseCredentialDestroyTransaction::TRANSACTIONTYPE)
37
->setNewValue(1);
38
39
$editor = id(new PassphraseCredentialTransactionEditor())
40
->setActor($viewer)
41
->setContinueOnMissingFields(true)
42
->setContentSourceFromRequest($request)
43
->applyTransactions($credential, $xactions);
44
45
return id(new AphrontRedirectResponse())->setURI($view_uri);
46
}
47
48
return $this->newDialog()
49
->setUser($viewer)
50
->setTitle(pht('Really destroy credential?'))
51
->appendChild(
52
pht(
53
'This credential will be deactivated and the secret will be '.
54
'unrecoverably destroyed. Anything relying on this credential '.
55
'will cease to function. This operation can not be undone.'))
56
->addSubmitButton(pht('Destroy Credential'))
57
->addCancelButton($view_uri);
58
}
59
60
}
61
62