Differential D20037 Diff 47866 src/applications/passphrase/controller/PassphraseCredentialRevealController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/passphrase/controller/PassphraseCredentialRevealController.php
Show All 15 Lines | $credential = id(new PassphraseCredentialQuery()) | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->needSecrets(true) | ->needSecrets(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$credential) { | if (!$credential) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$view_uri = '/K'.$credential->getID(); | $view_uri = $credential->getURI(); | ||||
$token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( | |||||
$viewer, | |||||
$request, | |||||
$view_uri); | |||||
$is_locked = $credential->getIsLocked(); | $is_locked = $credential->getIsLocked(); | ||||
if ($is_locked) { | if ($is_locked) { | ||||
return $this->newDialog() | return $this->newDialog() | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setTitle(pht('Credential is locked')) | ->setTitle(pht('Credential is locked')) | ||||
->appendChild( | ->appendChild( | ||||
pht( | pht( | ||||
'This credential can not be shown, because it is locked.')) | 'This credential can not be shown, because it is locked.')) | ||||
->addCancelButton($view_uri); | ->addCancelButton($view_uri); | ||||
} | } | ||||
if ($request->isFormPost()) { | if ($request->isFormOrHisecPost()) { | ||||
$secret = $credential->getSecret(); | $secret = $credential->getSecret(); | ||||
if (!$secret) { | if (!$secret) { | ||||
$body = pht('This credential has no associated secret.'); | $body = pht('This credential has no associated secret.'); | ||||
} else if (!strlen($secret->openEnvelope())) { | } else if (!strlen($secret->openEnvelope())) { | ||||
$body = pht('This credential has an empty secret.'); | $body = pht('This credential has an empty secret.'); | ||||
} else { | } else { | ||||
$body = id(new PHUIFormLayoutView()) | $body = id(new PHUIFormLayoutView()) | ||||
->appendChild( | ->appendChild( | ||||
Show All 20 Lines | if ($request->isFormOrHisecPost()) { | ||||
$xactions = array( | $xactions = array( | ||||
id(new PassphraseCredentialTransaction()) | id(new PassphraseCredentialTransaction()) | ||||
->setTransactionType($type_secret) | ->setTransactionType($type_secret) | ||||
->setNewValue(true), | ->setNewValue(true), | ||||
); | ); | ||||
$editor = id(new PassphraseCredentialTransactionEditor()) | $editor = id(new PassphraseCredentialTransactionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setCancelURI($view_uri) | |||||
->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->applyTransactions($credential, $xactions); | ->applyTransactions($credential, $xactions); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
} | } | ||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | ||||
Show All 21 Lines |