Path: blob/master/src/applications/auth/management/PhabricatorAuthManagementUntrustOAuthClientWorkflow.php
12256 views
<?php12final class PhabricatorAuthManagementUntrustOAuthClientWorkflow3extends PhabricatorAuthManagementWorkflow {45protected function didConstruct() {6$this7->setName('untrust-oauth-client')8->setExamples('**untrust-oauth-client** [--id client_id]')9->setSynopsis(10pht(11'Remove trust from an OAuth client. Users must manually confirm '.12'reauthorization of untrusted OAuth clients.'))13->setArguments(14array(15array(16'name' => 'id',17'param' => 'id',18'help' => pht('The id of the OAuth client.'),19),20));21}2223public function execute(PhutilArgumentParser $args) {24$id = $args->getArg('id');2526if (!$id) {27throw new PhutilArgumentUsageException(28pht(29'Specify an OAuth client ID with %s.',30'--id'));31}3233$client = id(new PhabricatorOAuthServerClientQuery())34->setViewer($this->getViewer())35->withIDs(array($id))36->executeOne();3738if (!$client) {39throw new PhutilArgumentUsageException(40pht(41'Failed to find an OAuth client with ID %s.', $id));42}4344if (!$client->getIsTrusted()) {45throw new PhutilArgumentUsageException(46pht(47'OAuth client "%s" is already untrusted.',48$client->getName()));49}5051$client->setIsTrusted(0);52$client->save();5354$console = PhutilConsole::getConsole();55$console->writeOut(56"%s\n",57pht(58'OAuth client "%s" is now trusted.',59$client->getName()));60}6162}636465