You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
- We currently have some bugs in account creation due to nontransactional user/email editing.
- We save $user, then try to save $email. This may fail for various reasons, commonly because the email isn't unique.
- This leaves us with a $user with no email.
- Also, logging of edits is somewhat inconsistent across various edit mechanisms.
- Move all editing to a `PhabricatorUserEditor` class.
- Handle some broken-data cases more gracefully.
Test Plan:
- Created and edited a user with `accountadmin`.
- Created a user with `add_user.php`
- Created and edited a user with People editor.
- Created a user with OAuth.
- Edited user information via Settings.
- Tried to create an OAuth user with a duplicate email address, got a proper error.
- Tried to create a user via People with a duplicate email address, got a proper error.
Reviewers: btrahan, vrana, jungejason
Reviewed By: btrahan
CC: tberman, aran
Maniphest Tasks: T1184
Differential Revision: https://secure.phabricator.com/D2569
Copy file name to clipboardexpand all lines: src/applications/auth/controller/oauthregistration/default/PhabricatorOAuthDefaultRegistrationController.php
+8-7
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,6 @@ public function processRequest() {
83
83
}
84
84
85
85
try {
86
-
$user->save();
87
86
88
87
// NOTE: We don't verify OAuth email addresses by default because
89
88
// OAuth providers might associate email addresses with accounts that
@@ -92,12 +91,14 @@ public function processRequest() {
92
91
// verifying an email address are high because having a corporate
93
92
// address at a company is sometimes the key to the castle.
94
93
95
-
$new_email = id(newPhabricatorUserEmail())
96
-
->setUserPHID($user->getPHID())
94
+
95
+
$email_obj = id(newPhabricatorUserEmail())
97
96
->setAddress($new_email)
98
-
->setIsPrimary(1)
99
-
->setIsVerified(0)
100
-
->save();
97
+
->setIsVerified(0);
98
+
99
+
id(newPhabricatorUserEditor())
100
+
->setActor($user)
101
+
->createNewUser($user, $email_obj);
101
102
102
103
$oauth_info->setUserID($user->getID());
103
104
$oauth_info->save();
@@ -106,7 +107,7 @@ public function processRequest() {
Copy file name to clipboardexpand all lines: src/applications/people/controller/settings/panels/password/PhabricatorUserPasswordSettingsPanelController.php
+5-2
Original file line number
Diff line number
Diff line change
@@ -79,13 +79,16 @@ public function processRequest() {
79
79
}
80
80
81
81
if (!$errors) {
82
-
$user->setPassword($pass);
83
82
// This write is unguarded because the CSRF token has already
84
83
// been checked in the call to $request->isFormPost() and
85
84
// the CSRF token depends on the password hash, so when it
86
85
// is changed here the CSRF token check will fail.
0 commit comments