@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.

Record account recovery email links in the user activity log and make the mail message reference the log

Summary:
Depends on D20672. Ref T13343. When a user requests an account access link via email:

- log it in the activity log; and
- reference the log in the mail.

This makes it easier to ban users misusing the feature, provided they're coming from a single remote address, and takes a few steps down the pathway toward a button in the mail that users can click to report the action, suspend account recovery for their account, etc.

Test Plan:
- Requested an email recovery link.
- Saw request appear in the user activity log.
- Saw a reference to the log entry in the mail footer.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13343

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

+43 -1
+2
src/__phutil_library_map__.php
··· 3216 3216 'PhabricatorEmailFormatSetting' => 'applications/settings/setting/PhabricatorEmailFormatSetting.php', 3217 3217 'PhabricatorEmailFormatSettingsPanel' => 'applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php', 3218 3218 'PhabricatorEmailLoginController' => 'applications/auth/controller/PhabricatorEmailLoginController.php', 3219 + 'PhabricatorEmailLoginUserLogType' => 'applications/people/userlog/PhabricatorEmailLoginUserLogType.php', 3219 3220 'PhabricatorEmailNotificationsSetting' => 'applications/settings/setting/PhabricatorEmailNotificationsSetting.php', 3220 3221 'PhabricatorEmailPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php', 3221 3222 'PhabricatorEmailRePrefixSetting' => 'applications/settings/setting/PhabricatorEmailRePrefixSetting.php', ··· 9343 9344 'PhabricatorEmailFormatSetting' => 'PhabricatorSelectSetting', 9344 9345 'PhabricatorEmailFormatSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 9345 9346 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', 9347 + 'PhabricatorEmailLoginUserLogType' => 'PhabricatorUserLogType', 9346 9348 'PhabricatorEmailNotificationsSetting' => 'PhabricatorSelectSetting', 9347 9349 'PhabricatorEmailPreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 9348 9350 'PhabricatorEmailRePrefixSetting' => 'PhabricatorSelectSetting',
+7 -1
src/applications/auth/controller/PhabricatorEmailLoginController.php
··· 104 104 if (!$errors) { 105 105 $target_address = new PhutilEmailAddress($target_email->getAddress()); 106 106 107 + $user_log = PhabricatorUserLog::initializeNewLog( 108 + $viewer, 109 + $target_user->getPHID(), 110 + PhabricatorEmailLoginUserLogType::LOGTYPE); 111 + 107 112 $mail_engine = id(new PhabricatorPeopleEmailLoginMailEngine()) 108 113 ->setSender($viewer) 109 114 ->setRecipient($target_user) 110 - ->setRecipientAddress($target_address); 115 + ->setRecipientAddress($target_address) 116 + ->setActivityLog($user_log); 111 117 112 118 try { 113 119 $mail_engine->validateMail();
+22
src/applications/people/mail/PhabricatorPeopleMailEngine.php
··· 6 6 private $sender; 7 7 private $recipient; 8 8 private $recipientAddress; 9 + private $activityLog; 9 10 10 11 final public function setSender(PhabricatorUser $sender) { 11 12 $this->sender = $sender; ··· 47 48 return ($this->recipientAddress !== null); 48 49 } 49 50 51 + final public function setActivityLog(PhabricatorUserLog $activity_log) { 52 + $this->activityLog = $activity_log; 53 + return $this; 54 + } 55 + 56 + final public function getActivityLog() { 57 + return $this->activityLog; 58 + } 59 + 50 60 final public function canSendMail() { 51 61 try { 52 62 $this->validateMail(); ··· 66 76 } else { 67 77 $recipient = $this->getRecipient(); 68 78 $mail->addTos(array($recipient->getPHID())); 79 + } 80 + 81 + $activity_log = $this->getActivityLog(); 82 + if ($activity_log) { 83 + $activity_log->save(); 84 + 85 + $body = array(); 86 + $body[] = rtrim($mail->getBody(), "\n"); 87 + $body[] = pht('Activity Log ID: #%d', $activity_log->getID()); 88 + $body = implode("\n\n", $body)."\n"; 89 + 90 + $mail->setBody($body); 69 91 } 70 92 71 93 $mail
+12
src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php
··· 1 + <?php 2 + 3 + final class PhabricatorEmailLoginUserLogType 4 + extends PhabricatorUserLogType { 5 + 6 + const LOGTYPE = 'email-login'; 7 + 8 + public function getLogTypeName() { 9 + return pht('Email: Recovery Link'); 10 + } 11 + 12 + }