@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "did verify email" event to Phabricator

Summary: Ref T7152. Gives us an event hook so we can go make users a member of any instance they've been invited to as soon as they verify an email address.

Test Plan:
- Used `bin/auth verify` to trigger the event.
- Build out the invite flow in rSERVICES.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7152

Differential Revision: https://secure.phabricator.com/D11752

+95
+4
src/__phutil_library_map__.php
··· 1372 1372 'PhabricatorAuthManagementStripWorkflow' => 'applications/auth/management/PhabricatorAuthManagementStripWorkflow.php', 1373 1373 'PhabricatorAuthManagementTrustOAuthClientWorkflow' => 'applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php', 1374 1374 'PhabricatorAuthManagementUntrustOAuthClientWorkflow' => 'applications/auth/management/PhabricatorAuthManagementUntrustOAuthClientWorkflow.php', 1375 + 'PhabricatorAuthManagementVerifyWorkflow' => 'applications/auth/management/PhabricatorAuthManagementVerifyWorkflow.php', 1375 1376 'PhabricatorAuthManagementWorkflow' => 'applications/auth/management/PhabricatorAuthManagementWorkflow.php', 1376 1377 'PhabricatorAuthNeedsApprovalController' => 'applications/auth/controller/PhabricatorAuthNeedsApprovalController.php', 1377 1378 'PhabricatorAuthNeedsMultiFactorController' => 'applications/auth/controller/PhabricatorAuthNeedsMultiFactorController.php', ··· 3768 3769 'DivinerLiveBook' => array( 3769 3770 'DivinerDAO', 3770 3771 'PhabricatorPolicyInterface', 3772 + 'PhabricatorDestructibleInterface', 3771 3773 ), 3772 3774 'DivinerLivePublisher' => 'DivinerPublisher', 3773 3775 'DivinerLiveSymbol' => array( 3774 3776 'DivinerDAO', 3775 3777 'PhabricatorPolicyInterface', 3776 3778 'PhabricatorMarkupInterface', 3779 + 'PhabricatorDestructibleInterface', 3777 3780 ), 3778 3781 'DivinerMainController' => 'DivinerController', 3779 3782 'DivinerPHPAtomizer' => 'DivinerAtomizer', ··· 4603 4606 'PhabricatorAuthManagementStripWorkflow' => 'PhabricatorAuthManagementWorkflow', 4604 4607 'PhabricatorAuthManagementTrustOAuthClientWorkflow' => 'PhabricatorAuthManagementWorkflow', 4605 4608 'PhabricatorAuthManagementUntrustOAuthClientWorkflow' => 'PhabricatorAuthManagementWorkflow', 4609 + 'PhabricatorAuthManagementVerifyWorkflow' => 'PhabricatorAuthManagementWorkflow', 4606 4610 'PhabricatorAuthManagementWorkflow' => 'PhabricatorManagementWorkflow', 4607 4611 'PhabricatorAuthNeedsApprovalController' => 'PhabricatorAuthController', 4608 4612 'PhabricatorAuthNeedsMultiFactorController' => 'PhabricatorAuthController',
+68
src/applications/auth/management/PhabricatorAuthManagementVerifyWorkflow.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthManagementVerifyWorkflow 4 + extends PhabricatorAuthManagementWorkflow { 5 + 6 + protected function didConstruct() { 7 + $this 8 + ->setName('verify') 9 + ->setExamples('**verify** __email__') 10 + ->setSynopsis( 11 + pht( 12 + 'Verify an unverified email address which is already attached to '. 13 + 'an account. This will also re-execute event hooks for addresses '. 14 + 'which are already verified.')) 15 + ->setArguments( 16 + array( 17 + array( 18 + 'name' => 'email', 19 + 'wildcard' => true, 20 + ), 21 + )); 22 + } 23 + 24 + public function execute(PhutilArgumentParser $args) { 25 + $emails = $args->getArg('email'); 26 + if (!$emails) { 27 + throw new PhutilArgumentUsageException( 28 + pht('You must specify the email to verify.')); 29 + } else if (count($emails) > 1) { 30 + throw new PhutilArgumentUsageException( 31 + pht('You can only verify one address at a time.')); 32 + } 33 + $address = head($emails); 34 + 35 + $email = id(new PhabricatorUserEmail())->loadOneWhere( 36 + 'address = %s', 37 + $address); 38 + if (!$email) { 39 + throw new PhutilArgumentUsageException( 40 + pht( 41 + 'No email exists with address "%s"!', 42 + $address)); 43 + } 44 + 45 + $viewer = $this->getViewer(); 46 + 47 + $user = id(new PhabricatorPeopleQuery()) 48 + ->setViewer($viewer) 49 + ->withPHIDs(array($email->getUserPHID())) 50 + ->executeOne(); 51 + if (!$user) { 52 + throw new Exception(pht('Email record has invalid user PHID!')); 53 + } 54 + 55 + $editor = id(new PhabricatorUserEditor()) 56 + ->setActor($viewer) 57 + ->verifyEmail($user, $email); 58 + 59 + $console = PhutilConsole::getConsole(); 60 + 61 + $console->writeOut( 62 + "%s\n", 63 + pht('Done.')); 64 + 65 + return 0; 66 + } 67 + 68 + }
+22
src/applications/people/editor/PhabricatorUserEditor.php
··· 93 93 94 94 $user->saveTransaction(); 95 95 96 + if ($email->getIsVerified()) { 97 + $this->didVerifyEmail($user, $email); 98 + } 99 + 96 100 return $this; 97 101 } 98 102 ··· 574 578 575 579 $user->endWriteLocking(); 576 580 $user->saveTransaction(); 581 + 582 + $this->didVerifyEmail($user, $email); 577 583 } 578 584 579 585 ··· 673 679 PhabricatorAuthSessionEngine::PASSWORD_TEMPORARY_TOKEN_TYPE, 674 680 )); 675 681 } 682 + 683 + private function didVerifyEmail( 684 + PhabricatorUser $user, 685 + PhabricatorUserEmail $email) { 686 + 687 + $event_type = PhabricatorEventType::TYPE_AUTH_DIDVERIFYEMAIL; 688 + $event_data = array( 689 + 'user' => $user, 690 + 'email' => $email, 691 + ); 692 + 693 + $event = id(new PhabricatorEvent($event_type, $event_data)) 694 + ->setUser($user); 695 + PhutilEventEngine::dispatchEvent($event); 696 + } 697 + 676 698 677 699 }
+1
src/infrastructure/events/constant/PhabricatorEventType.php
··· 30 30 const TYPE_PEOPLE_DIDRENDERMENU = 'people.didRenderMenu'; 31 31 const TYPE_AUTH_WILLREGISTERUSER = 'auth.willRegisterUser'; 32 32 const TYPE_AUTH_WILLLOGINUSER = 'auth.willLoginUser'; 33 + const TYPE_AUTH_DIDVERIFYEMAIL = 'auth.didVerifyEmail'; 33 34 34 35 const TYPE_SEARCH_DIDUPDATEINDEX = 'search.didUpdateIndex'; 35 36