[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/auth/controller/ -> PhabricatorAuthSSHKeyDeleteController.php (source)

   1  <?php
   2  
   3  final class PhabricatorAuthSSHKeyDeleteController
   4    extends PhabricatorAuthSSHKeyController {
   5  
   6    public function handleRequest(AphrontRequest $request) {
   7      $viewer = $this->getViewer();
   8  
   9      $key = id(new PhabricatorAuthSSHKeyQuery())
  10        ->setViewer($viewer)
  11        ->withIDs(array($request->getURIData('id')))
  12        ->requireCapabilities(
  13          array(
  14            PhabricatorPolicyCapability::CAN_VIEW,
  15            PhabricatorPolicyCapability::CAN_EDIT,
  16          ))
  17        ->executeOne();
  18      if (!$key) {
  19        return new Aphront404Response();
  20      }
  21  
  22      $cancel_uri = $key->getObject()->getSSHPublicKeyManagementURI($viewer);
  23  
  24      $token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
  25        $viewer,
  26        $request,
  27        $cancel_uri);
  28  
  29      if ($request->isFormPost()) {
  30        // TODO: It would be nice to write an edge transaction here or something.
  31        $key->delete();
  32        return id(new AphrontRedirectResponse())->setURI($cancel_uri);
  33      }
  34  
  35      $name = phutil_tag('strong', array(), $key->getName());
  36  
  37      return $this->newDialog()
  38        ->setTitle(pht('Really delete SSH Public Key?'))
  39        ->appendParagraph(
  40          pht(
  41            'The key "%s" will be permanently deleted, and you will not longer '.
  42            'be able to use the corresponding private key to authenticate.',
  43            $name))
  44        ->addSubmitButton(pht('Delete Public Key'))
  45        ->addCancelButton($cancel_uri);
  46    }
  47  
  48  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1