Differential D19903 Diff 47591 src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php
<?php | <?php | ||||
final class PhabricatorAuthManagementRecoverWorkflow | final class PhabricatorAuthManagementRecoverWorkflow | ||||
extends PhabricatorAuthManagementWorkflow { | extends PhabricatorAuthManagementWorkflow { | ||||
protected function didConstruct() { | protected function didConstruct() { | ||||
$this | $this | ||||
->setName('recover') | ->setName('recover') | ||||
->setExamples('**recover** __username__') | ->setExamples('**recover** __username__') | ||||
->setSynopsis( | ->setSynopsis( | ||||
pht( | pht( | ||||
'Recover access to an account if you have locked yourself out '. | 'Recover access to an account if you have locked yourself out '. | ||||
'of Phabricator.')) | 'of Phabricator.')) | ||||
->setArguments( | ->setArguments( | ||||
array( | array( | ||||
'username' => array( | array( | ||||
'name' => 'force-full-session', | |||||
'help' => pht( | |||||
'Recover directly into a full session without requiring MFA '. | |||||
'or other login checks.'), | |||||
), | |||||
array( | |||||
'name' => 'username', | 'name' => 'username', | ||||
'wildcard' => true, | 'wildcard' => true, | ||||
), | ), | ||||
)); | )); | ||||
} | } | ||||
public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
$usernames = $args->getArg('username'); | $usernames = $args->getArg('username'); | ||||
Show All 24 Lines | if (!$user->canEstablishWebSessions()) { | ||||
pht( | pht( | ||||
'This account ("%s") can not establish web sessions, so it is '. | 'This account ("%s") can not establish web sessions, so it is '. | ||||
'not possible to generate a functional recovery link. Special '. | 'not possible to generate a functional recovery link. Special '. | ||||
'accounts like daemons and mailing lists can not log in via the '. | 'accounts like daemons and mailing lists can not log in via the '. | ||||
'web UI.', | 'web UI.', | ||||
$username)); | $username)); | ||||
} | } | ||||
$force_full_session = $args->getArg('force-full-session'); | |||||
$engine = new PhabricatorAuthSessionEngine(); | $engine = new PhabricatorAuthSessionEngine(); | ||||
$onetime_uri = $engine->getOneTimeLoginURI( | $onetime_uri = $engine->getOneTimeLoginURI( | ||||
$user, | $user, | ||||
null, | null, | ||||
PhabricatorAuthSessionEngine::ONETIME_RECOVER); | PhabricatorAuthSessionEngine::ONETIME_RECOVER, | ||||
$force_full_session); | |||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$console->writeOut( | $console->writeOut( | ||||
pht( | pht( | ||||
'Use this link to recover access to the "%s" account from the web '. | 'Use this link to recover access to the "%s" account from the web '. | ||||
'interface:', | 'interface:', | ||||
$username)); | $username)); | ||||
$console->writeOut("\n\n"); | $console->writeOut("\n\n"); | ||||
Show All 13 Lines |