Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / auth / management / PhabricatorAuthManagementUntrustOAuthClientWorkflow.php
bloba0b3e02fa442438f88966f9b5ecf5ce2d2601ca3
1 <?php
3 final class PhabricatorAuthManagementUntrustOAuthClientWorkflow
4 extends PhabricatorAuthManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('untrust-oauth-client')
9 ->setExamples('**untrust-oauth-client** [--id client_id]')
10 ->setSynopsis(
11 pht(
12 'Set Phabricator to not trust an OAuth client. Phabricator '.
13 'redirects to trusted OAuth clients that users have authorized '.
14 'without user intervention.'))
15 ->setArguments(
16 array(
17 array(
18 'name' => 'id',
19 'param' => 'id',
20 'help' => pht('The id of the OAuth client.'),
22 ));
25 public function execute(PhutilArgumentParser $args) {
26 $id = $args->getArg('id');
28 if (!$id) {
29 throw new PhutilArgumentUsageException(
30 pht(
31 'Specify an OAuth client ID with %s.',
32 '--id'));
35 $client = id(new PhabricatorOAuthServerClientQuery())
36 ->setViewer($this->getViewer())
37 ->withIDs(array($id))
38 ->executeOne();
40 if (!$client) {
41 throw new PhutilArgumentUsageException(
42 pht(
43 'Failed to find an OAuth client with ID %s.', $id));
46 if (!$client->getIsTrusted()) {
47 throw new PhutilArgumentUsageException(
48 pht(
49 'Phabricator already does not trust OAuth client "%s".',
50 $client->getName()));
53 $client->setIsTrusted(0);
54 $client->save();
56 $console = PhutilConsole::getConsole();
57 $console->writeOut(
58 "%s\n",
59 pht(
60 'Updated; Phabricator does not trust OAuth client %s.',
61 $client->getName()));