Differential D21766 Diff 51885 src/applications/auth/management/PhabricatorAuthManagementUntrustOAuthClientWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/management/PhabricatorAuthManagementUntrustOAuthClientWorkflow.php
<?php | <?php | ||||
final class PhabricatorAuthManagementUntrustOAuthClientWorkflow | final class PhabricatorAuthManagementUntrustOAuthClientWorkflow | ||||
extends PhabricatorAuthManagementWorkflow { | extends PhabricatorAuthManagementWorkflow { | ||||
protected function didConstruct() { | protected function didConstruct() { | ||||
$this | $this | ||||
->setName('untrust-oauth-client') | ->setName('untrust-oauth-client') | ||||
->setExamples('**untrust-oauth-client** [--id client_id]') | ->setExamples('**untrust-oauth-client** [--id client_id]') | ||||
->setSynopsis( | ->setSynopsis( | ||||
pht( | pht( | ||||
'Set Phabricator to not trust an OAuth client. Phabricator '. | 'Remove trust from an OAuth client. Users must manually confirm '. | ||||
'redirects to trusted OAuth clients that users have authorized '. | 'reauthorization of untrusted OAuth clients.')) | ||||
'without user intervention.')) | |||||
->setArguments( | ->setArguments( | ||||
array( | array( | ||||
array( | array( | ||||
'name' => 'id', | 'name' => 'id', | ||||
'param' => 'id', | 'param' => 'id', | ||||
'help' => pht('The id of the OAuth client.'), | 'help' => pht('The id of the OAuth client.'), | ||||
), | ), | ||||
)); | )); | ||||
Show All 18 Lines | if (!$client) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'Failed to find an OAuth client with ID %s.', $id)); | 'Failed to find an OAuth client with ID %s.', $id)); | ||||
} | } | ||||
if (!$client->getIsTrusted()) { | if (!$client->getIsTrusted()) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'Phabricator already does not trust OAuth client "%s".', | 'OAuth client "%s" is already untrusted.', | ||||
$client->getName())); | $client->getName())); | ||||
} | } | ||||
$client->setIsTrusted(0); | $client->setIsTrusted(0); | ||||
$client->save(); | $client->save(); | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$console->writeOut( | $console->writeOut( | ||||
"%s\n", | "%s\n", | ||||
pht( | pht( | ||||
'Updated; Phabricator does not trust OAuth client %s.', | 'OAuth client "%s" is now trusted.', | ||||
$client->getName())); | $client->getName())); | ||||
} | } | ||||
} | } |