Path: blob/master/src/applications/conduit/controller/PhabricatorConduitTokenHandshakeController.php
12256 views
<?php12final class PhabricatorConduitTokenHandshakeController3extends PhabricatorConduitController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(9$viewer,10$request,11'/');1213$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();14$token = PhabricatorConduitToken::initializeNewToken(15$viewer->getPHID(),16PhabricatorConduitToken::TYPE_COMMANDLINE);17$token->save();18unset($unguarded);1920$form = id(new AphrontFormView())21->setUser($viewer)22->appendRemarkupInstructions(23pht(24'Copy-paste the API Token below to grant access to your account.'))25->appendChild(26id(new AphrontFormTextControl())27->setLabel(pht('API Token'))28->setValue($token->getToken()))29->appendRemarkupInstructions(30pht(31'This will authorize the requesting script to act on your behalf '.32'permanently, like giving the script your account password.'))33->appendRemarkupInstructions(34pht(35'If you change your mind, you can revoke this token later in '.36'{nav icon=wrench,name=Settings > Conduit API Tokens}.'));3738return $this->newDialog()39->setTitle(pht('Grant Account Access'))40->setWidth(AphrontDialogView::WIDTH_FULL)41->appendForm($form)42->addCancelButton('/');43}4445}464748