Path: blob/master/src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php
12256 views
<?php12final class PhabricatorAuthManagementTrustOAuthClientWorkflow3extends PhabricatorAuthManagementWorkflow {45protected function didConstruct() {6$this7->setName('trust-oauth-client')8->setExamples('**trust-oauth-client** [--id client_id]')9->setSynopsis(10pht(11'Mark an OAuth client as trusted. Trusted OAuth clients may be '.12'reauthorized without requiring users to manually confirm the '.13'action.'))14->setArguments(15array(16array(17'name' => 'id',18'param' => 'id',19'help' => pht('The id of the OAuth client.'),20),21));22}2324public function execute(PhutilArgumentParser $args) {25$id = $args->getArg('id');2627if (!$id) {28throw new PhutilArgumentUsageException(29pht(30'Specify an OAuth client id with "--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 trusted.',48$client->getName()));49}5051$client->setIsTrusted(1);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