Path: blob/master/src/applications/auth/management/PhabricatorAuthManagementVerifyWorkflow.php
12256 views
<?php12final class PhabricatorAuthManagementVerifyWorkflow3extends PhabricatorAuthManagementWorkflow {45protected function didConstruct() {6$this7->setName('verify')8->setExamples('**verify** __email__')9->setSynopsis(10pht(11'Verify an unverified email address which is already attached to '.12'an account. This will also re-execute event hooks for addresses '.13'which are already verified.'))14->setArguments(15array(16array(17'name' => 'email',18'wildcard' => true,19),20));21}2223public function execute(PhutilArgumentParser $args) {24$emails = $args->getArg('email');25if (!$emails) {26throw new PhutilArgumentUsageException(27pht('You must specify the email to verify.'));28} else if (count($emails) > 1) {29throw new PhutilArgumentUsageException(30pht('You can only verify one address at a time.'));31}32$address = head($emails);3334$email = id(new PhabricatorUserEmail())->loadOneWhere(35'address = %s',36$address);37if (!$email) {38throw new PhutilArgumentUsageException(39pht(40'No email exists with address "%s"!',41$address));42}4344$viewer = $this->getViewer();4546$user = id(new PhabricatorPeopleQuery())47->setViewer($viewer)48->withPHIDs(array($email->getUserPHID()))49->executeOne();50if (!$user) {51throw new Exception(pht('Email record has invalid user PHID!'));52}5354$editor = id(new PhabricatorUserEditor())55->setActor($viewer)56->verifyEmail($user, $email);5758$console = PhutilConsole::getConsole();5960$console->writeOut(61"%s\n",62pht('Done.'));6364return 0;65}6667}686970