Differential D25002 Diff 39 src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php
<?php | <?php | ||||
final class PhabricatorAuthManagementTrustOAuthClientWorkflow | final class PhabricatorAuthManagementTrustOAuthClientWorkflow | ||||
extends PhabricatorAuthManagementWorkflow { | extends PhabricatorAuthManagementWorkflow { | ||||
protected function didConstruct() { | protected function didConstruct() { | ||||
$this | $this | ||||
->setName('trust-oauth-client') | ->setName('trust-oauth-client') | ||||
->setExamples('**trust-oauth-client** [--id client_id]') | ->setExamples('**trust-oauth-client** [--id client_id]') | ||||
->setSynopsis( | ->setSynopsis( | ||||
pht( | pht( | ||||
'Set Phabricator to trust an OAuth client. Phabricator '. | 'Set %s to trust an OAuth client. %s '. | ||||
'redirects to trusted OAuth clients that users have authorized '. | 'redirects to trusted OAuth clients that users have authorized '. | ||||
'without user intervention.')) | 'without user intervention.', | ||||
PhabricatorPlatformSite::getName(), | |||||
PhabricatorPlatformSite::getName())) | |||||
->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 trusts OAuth client "%s".', | '%s already trusts OAuth client "%s".', | ||||
PhabricatorPlatformSite::getName(), | |||||
$client->getName())); | $client->getName())); | ||||
} | } | ||||
$client->setIsTrusted(1); | $client->setIsTrusted(1); | ||||
$client->save(); | $client->save(); | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$console->writeOut( | $console->writeOut( | ||||
"%s\n", | "%s\n", | ||||
pht( | pht( | ||||
'Updated; Phabricator trusts OAuth client %s.', | 'Updated; %s trusts OAuth client %s.', | ||||
PhabricatorPlatformSite::getName(), | |||||
$client->getName())); | $client->getName())); | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0