Path: blob/master/src/applications/conduit/controller/PhabricatorConduitTokenController.php
12256 views
<?php12final class PhabricatorConduitTokenController3extends PhabricatorConduitController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(9$viewer,10$this->getRequest(),11'/');1213// Ideally we'd like to verify this, but it's fine to leave it unguarded14// for now and verifying it would need some Ajax junk or for the user to15// click a button or similar.16$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();1718$old_token = id(new PhabricatorConduitCertificateToken())19->loadOneWhere(20'userPHID = %s',21$viewer->getPHID());22if ($old_token) {23$old_token->delete();24}2526$token = id(new PhabricatorConduitCertificateToken())27->setUserPHID($viewer->getPHID())28->setToken(Filesystem::readRandomCharacters(40))29->save();3031unset($unguarded);3233$pre_instructions = pht(34'Copy and paste this token into the prompt given to you by '.35'`arc install-certificate`');3637$post_instructions = pht(38'After you copy and paste this token, `arc` will complete '.39'the certificate install process for you.');4041Javelin::initBehavior('select-on-click');4243$form = id(new AphrontFormView())44->setUser($viewer)45->appendRemarkupInstructions($pre_instructions)46->appendChild(47id(new AphrontFormTextAreaControl())48->setLabel(pht('Token'))49->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)50->setReadonly(true)51->setSigil('select-on-click')52->setValue($token->getToken()))53->appendRemarkupInstructions($post_instructions);5455$crumbs = $this->buildApplicationCrumbs();56$crumbs->addTextCrumb(pht('Install Certificate'));57$crumbs->setBorder(true);5859$object_box = id(new PHUIObjectBoxView())60->setHeaderText(pht('Certificate Token'))61->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)62->setForm($form);6364$title = pht('Certificate Install Token');6566$header = id(new PHUIHeaderView())67->setHeader($title);6869$view = id(new PHUITwoColumnView())70->setHeader($header)71->setFooter($object_box);7273return $this->newPage()74->setTitle($title)75->setCrumbs($crumbs)76->appendChild($view);77}7879}808182