Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / management / PhabricatorAuthManagementUntrustOAuthClientWorkflow.php
blobd3d7ff3aeab53a9a4fe57ca3b333390bbf1e9b7a
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 'Remove trust from an OAuth client. Users must manually confirm '.
13 'reauthorization of untrusted OAuth clients.'))
14 ->setArguments(
15 array(
16 array(
17 'name' => 'id',
18 'param' => 'id',
19 'help' => pht('The id of the OAuth client.'),
21 ));
24 public function execute(PhutilArgumentParser $args) {
25 $id = $args->getArg('id');
27 if (!$id) {
28 throw new PhutilArgumentUsageException(
29 pht(
30 'Specify an OAuth client ID with %s.',
31 '--id'));
34 $client = id(new PhabricatorOAuthServerClientQuery())
35 ->setViewer($this->getViewer())
36 ->withIDs(array($id))
37 ->executeOne();
39 if (!$client) {
40 throw new PhutilArgumentUsageException(
41 pht(
42 'Failed to find an OAuth client with ID %s.', $id));
45 if (!$client->getIsTrusted()) {
46 throw new PhutilArgumentUsageException(
47 pht(
48 'OAuth client "%s" is already untrusted.',
49 $client->getName()));
52 $client->setIsTrusted(0);
53 $client->save();
55 $console = PhutilConsole::getConsole();
56 $console->writeOut(
57 "%s\n",
58 pht(
59 'OAuth client "%s" is now trusted.',
60 $client->getName()));