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

Allow installs to customize mail body guidance in the "Email Login" and "Set Password" emails

Summary:
Depends on D20662. Ref T13343. Installs may reasonably want to change the guidance users receive in "Email Login"/"Forgot Password" email.

(In an upcoming change I plan to supply a piece of default guidance, but Auth Messages need a few tweaks for this.)

There's probably little reason to provide guidance on the "Set Password" flow, but any guidance one might issue on the "Email Login" flow probably doesn't make sense on the "Set Password" flow, so I've included it mostly to make it clear that this is a different flow from a user perspective.

Test Plan:
- Set custom "Email Login" and "Set Password" messages.
- Generated "Email Login" mail by using the "Login via email" link on the login screen.
- Generated "Set Password" email by trying to set a password on an account with no password yet.
- Saw my custom messages in the resulting mail bodies.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13343

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

+64 -6
+4
src/__phutil_library_map__.php
··· 2265 2265 'PhabricatorAuthDisableController' => 'applications/auth/controller/config/PhabricatorAuthDisableController.php', 2266 2266 'PhabricatorAuthDowngradeSessionController' => 'applications/auth/controller/PhabricatorAuthDowngradeSessionController.php', 2267 2267 'PhabricatorAuthEditController' => 'applications/auth/controller/config/PhabricatorAuthEditController.php', 2268 + 'PhabricatorAuthEmailLoginMessageType' => 'applications/auth/message/PhabricatorAuthEmailLoginMessageType.php', 2269 + 'PhabricatorAuthEmailSetPasswordMessageType' => 'applications/auth/message/PhabricatorAuthEmailSetPasswordMessageType.php', 2268 2270 'PhabricatorAuthFactor' => 'applications/auth/factor/PhabricatorAuthFactor.php', 2269 2271 'PhabricatorAuthFactorConfig' => 'applications/auth/storage/PhabricatorAuthFactorConfig.php', 2270 2272 'PhabricatorAuthFactorConfigQuery' => 'applications/auth/query/PhabricatorAuthFactorConfigQuery.php', ··· 8220 8222 'PhabricatorAuthDisableController' => 'PhabricatorAuthProviderConfigController', 8221 8223 'PhabricatorAuthDowngradeSessionController' => 'PhabricatorAuthController', 8222 8224 'PhabricatorAuthEditController' => 'PhabricatorAuthProviderConfigController', 8225 + 'PhabricatorAuthEmailLoginMessageType' => 'PhabricatorAuthMessageType', 8226 + 'PhabricatorAuthEmailSetPasswordMessageType' => 'PhabricatorAuthMessageType', 8223 8227 'PhabricatorAuthFactor' => 'Phobject', 8224 8228 'PhabricatorAuthFactorConfig' => array( 8225 8229 'PhabricatorAuthDAO',
+18
src/applications/auth/message/PhabricatorAuthEmailLoginMessageType.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthEmailLoginMessageType 4 + extends PhabricatorAuthMessageType { 5 + 6 + const MESSAGEKEY = 'mail.login'; 7 + 8 + public function getDisplayName() { 9 + return pht('Mail Body: Email Login'); 10 + } 11 + 12 + public function getShortDescription() { 13 + return pht( 14 + 'Guidance in the message body when users request an email link '. 15 + 'to access their account.'); 16 + } 17 + 18 + }
+18
src/applications/auth/message/PhabricatorAuthEmailSetPasswordMessageType.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthEmailSetPasswordMessageType 4 + extends PhabricatorAuthMessageType { 5 + 6 + const MESSAGEKEY = 'mail.set-password'; 7 + 8 + public function getDisplayName() { 9 + return pht('Mail Body: Set Password'); 10 + } 11 + 12 + public function getShortDescription() { 13 + return pht( 14 + 'Guidance in the message body when users set a password on an account '. 15 + 'which did not previously have a password.'); 16 + } 17 + 18 + }
+1
src/applications/auth/message/PhabricatorAuthMessageType.php
··· 28 28 } 29 29 30 30 abstract public function getDisplayName(); 31 + abstract public function getShortDescription(); 31 32 32 33 }
+1 -1
src/applications/auth/message/PhabricatorAuthWelcomeMailMessageType.php
··· 6 6 const MESSAGEKEY = 'mail.welcome'; 7 7 8 8 public function getDisplayName() { 9 - return pht('Welcome Email Body'); 9 + return pht('Mail Body: Welcome'); 10 10 } 11 11 12 12 public function getShortDescription() {
+1 -1
src/applications/auth/storage/PhabricatorAuthMessage.php
··· 45 45 } 46 46 47 47 public function getURI() { 48 - return urisprintf('/auth/message/%s', $this->getID()); 48 + return urisprintf('/auth/message/%s/', $this->getID()); 49 49 } 50 50 51 51 public function attachMessageType(PhabricatorAuthMessageType $type) {
+21 -4
src/applications/people/mail/PhabricatorPeopleEmailLoginMailEngine.php
··· 43 43 $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 44 44 $have_passwords = $this->isPasswordAuthEnabled(); 45 45 46 + $body = array(); 47 + 48 + if ($is_set_password) { 49 + $message_key = PhabricatorAuthEmailSetPasswordMessageType::MESSAGEKEY; 50 + } else { 51 + $message_key = PhabricatorAuthEmailLoginMessageType::MESSAGEKEY; 52 + } 53 + 54 + $message_body = PhabricatorAuthMessage::loadMessageText( 55 + $recipient, 56 + $message_key); 57 + if (strlen($message_body)) { 58 + $body[] = $this->newRemarkupText($message_body); 59 + } 60 + 46 61 if ($have_passwords) { 47 62 if ($is_set_password) { 48 - $body = pht( 63 + $body[] = pht( 49 64 'You can use this link to set a password on your account:'. 50 65 "\n\n %s\n", 51 66 $login_uri); 52 67 } else if ($is_serious) { 53 - $body = pht( 68 + $body[] = pht( 54 69 "You can use this link to reset your Phabricator password:". 55 70 "\n\n %s\n", 56 71 $login_uri); 57 72 } else { 58 - $body = pht( 73 + $body[] = pht( 59 74 "Condolences on forgetting your password. You can use this ". 60 75 "link to reset it:\n\n". 61 76 " %s\n\n". ··· 68 83 69 84 } 70 85 } else { 71 - $body = pht( 86 + $body[] = pht( 72 87 "You can use this login link to regain access to your Phabricator ". 73 88 "account:". 74 89 "\n\n". 75 90 " %s\n", 76 91 $login_uri); 77 92 } 93 + 94 + $body = implode("\n\n", $body); 78 95 79 96 return id(new PhabricatorMetaMTAMail()) 80 97 ->setSubject($subject)