Differential D15946 Diff 38400 src/applications/auth/controller/PhabricatorAuthSSHKeyEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/PhabricatorAuthSSHKeyEditController.php
<?php | <?php | ||||
final class PhabricatorAuthSSHKeyEditController | final class PhabricatorAuthSSHKeyEditController | ||||
extends PhabricatorAuthSSHKeyController { | extends PhabricatorAuthSSHKeyController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
if ($id) { | if ($id) { | ||||
$key = id(new PhabricatorAuthSSHKeyQuery()) | $key = id(new PhabricatorAuthSSHKeyQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->withIsActive(true) | |||||
->requireCapabilities( | ->requireCapabilities( | ||||
array( | array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$key) { | if (!$key) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
$e_key = pht('Invalid'); | $e_key = pht('Invalid'); | ||||
$errors[] = $ex->getMessage(); | $errors[] = $ex->getMessage(); | ||||
} | } | ||||
} | } | ||||
if (!$errors) { | if (!$errors) { | ||||
try { | try { | ||||
$key->save(); | $key->save(); | ||||
return id(new AphrontRedirectResponse())->setURI($cancel_uri); | return id(new AphrontRedirectResponse())->setURI($key->getURI()); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$e_key = pht('Duplicate'); | $e_key = pht('Duplicate'); | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'This public key is already associated with another user or '. | 'This public key is already associated with another user or '. | ||||
'device. Each key must unambiguously identify a single unique '. | 'device. Each key must unambiguously identify a single unique '. | ||||
'owner.'); | 'owner.'); | ||||
} | } | ||||
} | } | ||||
Show All 36 Lines |