Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14747353
D20102.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D20102.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3899,6 +3899,7 @@
'PhabricatorPeopleTransactionQuery' => 'applications/people/query/PhabricatorPeopleTransactionQuery.php',
'PhabricatorPeopleUserFunctionDatasource' => 'applications/people/typeahead/PhabricatorPeopleUserFunctionDatasource.php',
'PhabricatorPeopleUserPHIDType' => 'applications/people/phid/PhabricatorPeopleUserPHIDType.php',
+ 'PhabricatorPeopleUsernameMailEngine' => 'applications/people/mail/PhabricatorPeopleUsernameMailEngine.php',
'PhabricatorPeopleWelcomeController' => 'applications/people/controller/PhabricatorPeopleWelcomeController.php',
'PhabricatorPeopleWelcomeMailEngine' => 'applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php',
'PhabricatorPhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorPhabricatorAuthProvider.php',
@@ -9895,6 +9896,7 @@
'PhabricatorPeopleTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorPeopleUserFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorPeopleUserPHIDType' => 'PhabricatorPHIDType',
+ 'PhabricatorPeopleUsernameMailEngine' => 'PhabricatorPeopleMailEngine',
'PhabricatorPeopleWelcomeController' => 'PhabricatorPeopleController',
'PhabricatorPeopleWelcomeMailEngine' => 'PhabricatorPeopleMailEngine',
'PhabricatorPhabricatorAuthProvider' => 'PhabricatorOAuth2AuthProvider',
diff --git a/src/applications/people/mail/PhabricatorPeopleUsernameMailEngine.php b/src/applications/people/mail/PhabricatorPeopleUsernameMailEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/mail/PhabricatorPeopleUsernameMailEngine.php
@@ -0,0 +1,60 @@
+<?php
+
+final class PhabricatorPeopleUsernameMailEngine
+ extends PhabricatorPeopleMailEngine {
+
+ private $oldUsername;
+ private $newUsername;
+
+ public function setNewUsername($new_username) {
+ $this->newUsername = $new_username;
+ return $this;
+ }
+
+ public function getNewUsername() {
+ return $this->newUsername;
+ }
+
+ public function setOldUsername($old_username) {
+ $this->oldUsername = $old_username;
+ return $this;
+ }
+
+ public function getOldUsername() {
+ return $this->oldUsername;
+ }
+
+ public function validateMail() {
+ return;
+ }
+
+ protected function newMail() {
+ $sender = $this->getSender();
+ $recipient = $this->getRecipient();
+
+ $sender_username = $sender->getUsername();
+ $sender_realname = $sender->getRealName();
+
+ $old_username = $this->getOldUsername();
+ $new_username = $this->getNewUsername();
+
+ $body = sprintf(
+ "%s\n\n %s\n %s\n",
+ pht(
+ '%s (%s) has changed your Phabricator username.',
+ $sender_username,
+ $sender_realname),
+ pht(
+ 'Old Username: %s',
+ $old_username),
+ pht(
+ 'New Username: %s',
+ $new_username));
+
+ return id(new PhabricatorMetaMTAMail())
+ ->addTos(array($recipient->getPHID()))
+ ->setSubject(pht('[Phabricator] Username Changed'))
+ ->setBody($body);
+ }
+
+}
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
@@ -555,55 +555,6 @@
}
}
- public function sendUsernameChangeEmail(
- PhabricatorUser $admin,
- $old_username) {
-
- $admin_username = $admin->getUserName();
- $admin_realname = $admin->getRealName();
- $new_username = $this->getUserName();
-
- $password_instructions = null;
- if (PhabricatorPasswordAuthProvider::getPasswordProvider()) {
- $engine = new PhabricatorAuthSessionEngine();
- $uri = $engine->getOneTimeLoginURI(
- $this,
- null,
- PhabricatorAuthSessionEngine::ONETIME_USERNAME);
- $password_instructions = sprintf(
- "%s\n\n %s\n\n%s\n",
- pht(
- "If you use a password to login, you'll need to reset it ".
- "before you can login again. You can reset your password by ".
- "following this link:"),
- $uri,
- pht(
- "And, of course, you'll need to use your new username to login ".
- "from now on. If you use OAuth to login, nothing should change."));
- }
-
- $body = sprintf(
- "%s\n\n %s\n %s\n\n%s",
- pht(
- '%s (%s) has changed your Phabricator username.',
- $admin_username,
- $admin_realname),
- pht(
- 'Old Username: %s',
- $old_username),
- pht(
- 'New Username: %s',
- $new_username),
- $password_instructions);
-
- $mail = id(new PhabricatorMetaMTAMail())
- ->addTos(array($this->getPHID()))
- ->setForceDelivery(true)
- ->setSubject(pht('[Phabricator] Username Changed'))
- ->setBody($body)
- ->saveAndSend();
- }
-
public static function describeValidUsername() {
return pht(
'Usernames must contain only numbers, letters, period, underscore and '.
diff --git a/src/applications/people/xaction/PhabricatorUserUsernameTransaction.php b/src/applications/people/xaction/PhabricatorUserUsernameTransaction.php
--- a/src/applications/people/xaction/PhabricatorUserUsernameTransaction.php
+++ b/src/applications/people/xaction/PhabricatorUserUsernameTransaction.php
@@ -18,18 +18,27 @@
}
public function applyExternalEffects($object, $value) {
+ $actor = $this->getActor();
$user = $object;
+ $old_username = $this->getOldValue();
+ $new_username = $this->getNewValue();
+
$this->newUserLog(PhabricatorUserLog::ACTION_CHANGE_USERNAME)
- ->setOldValue($this->getOldValue())
- ->setNewValue($value)
+ ->setOldValue($old_username)
+ ->setNewValue($new_username)
->save();
// The SSH key cache currently includes usernames, so dirty it. See T12554
// for discussion.
PhabricatorAuthSSHKeyQuery::deleteSSHKeyCache();
- $user->sendUsernameChangeEmail($this->getActor(), $this->getOldValue());
+ id(new PhabricatorPeopleUsernameMailEngine())
+ ->setSender($actor)
+ ->setRecipient($object)
+ ->setOldUsername($old_username)
+ ->setNewUsername($new_username)
+ ->sendMail();
}
public function getTitle() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 10:05 AM (4 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7029810
Default Alt Text
D20102.diff (6 KB)
Attached To
Mode
D20102: Remove one-time login from username change email
Attached
Detach File
Event Timeline
Log In to Comment