diff --git a/src/applications/diffusion/query/DiffusionResolveUserQuery.php b/src/applications/diffusion/query/DiffusionResolveUserQuery.php --- a/src/applications/diffusion/query/DiffusionResolveUserQuery.php +++ b/src/applications/diffusion/query/DiffusionResolveUserQuery.php @@ -93,7 +93,7 @@ private function findUserByEmailAddress($email_address) { - $by_email = PhabricatorUser::loadOneWithEmailAddress($email_address); + $by_email = PhabricatorUser::loadOneWithVerifiedEmailAddress($email_address); if ($by_email) { return $by_email->getPHID(); diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -652,6 +652,28 @@ return $this->getUsername(); } + /** + * Load one user from their verified email address. + * @param string $address + * @return PhabricatorUser|null + */ + public static function loadOneWithVerifiedEmailAddress($address) { + $email = id(new PhabricatorUserEmail())->loadOneWhere( + 'address = %s AND isVerified = 1', + $address); + if (!$email) { + return null; + } + return id(new PhabricatorUser())->loadOneWhere( + 'phid = %s', + $email->getUserPHID()); + } + + /** + * Load one user from their potentially unverified email address. + * @param string $address + * @return PhabricatorUser|null + */ public static function loadOneWithEmailAddress($address) { $email = id(new PhabricatorUserEmail())->loadOneWhere( 'address = %s', diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php --- a/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php @@ -281,7 +281,7 @@ $user->getMonogram())); $emails = id(new PhabricatorUserEmail())->loadAllWhere( - 'userPHID = %s', + 'userPHID = %s AND isVerified = 1', $user->getPHID()); if ($emails) { $this->rebuildEmails(mpull($emails, 'getAddress'));