mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 20:52:43 +01:00
34 lines
817 B
PHP
34 lines
817 B
PHP
|
<?php
|
||
|
|
||
|
abstract class PhabricatorAuthSSHKeyController
|
||
|
extends PhabricatorAuthController {
|
||
|
|
||
|
protected function newKeyForObjectPHID($object_phid) {
|
||
|
$viewer = $this->getViewer();
|
||
|
|
||
|
$object = id(new PhabricatorObjectQuery())
|
||
|
->setViewer($viewer)
|
||
|
->withPHIDs(array($object_phid))
|
||
|
->requireCapabilities(
|
||
|
array(
|
||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||
|
))
|
||
|
->executeOne();
|
||
|
if (!$object) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
// If this kind of object can't have SSH keys, don't let the viewer
|
||
|
// add them.
|
||
|
if (!($object instanceof PhabricatorSSHPublicKeyInterface)) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return id(new PhabricatorAuthSSHKey())
|
||
|
->setObjectPHID($object_phid)
|
||
|
->attachObject($object);
|
||
|
}
|
||
|
|
||
|
}
|