mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:03:44 +08:00
FIX: User merge should not fail when primary email address is missing
The merge process might move all email addresses of the source user to the target user. Destroying the source user failed in that case.
This commit is contained in:
parent
313ff264f2
commit
b970b072f6
|
@ -347,7 +347,11 @@ class UserMerger
|
|||
|
||||
def delete_source_user
|
||||
@source_user.reload
|
||||
@source_user.update_attribute(:admin, false)
|
||||
@source_user.update_attributes(
|
||||
admin: false,
|
||||
email: "#{@source_user.username}_#{SecureRandom.hex}@no-email.invalid"
|
||||
)
|
||||
|
||||
UserDestroyer.new(Discourse.system_user).destroy(@source_user)
|
||||
end
|
||||
|
||||
|
|
|
@ -953,6 +953,15 @@ describe UserMerger do
|
|||
expect(User.find_by_username(source_user.username)).to be_nil
|
||||
end
|
||||
|
||||
it "deletes the source user even when it is a member of a group that grants a trust level" do
|
||||
group = Fabricate(:group, grant_trust_level: 3)
|
||||
group.bulk_add([source_user.id, target_user.id])
|
||||
|
||||
merge_users!
|
||||
|
||||
expect(User.find_by_username(source_user.username)).to be_nil
|
||||
end
|
||||
|
||||
it "deletes external auth infos of source user" do
|
||||
FacebookUserInfo.create(user_id: source_user.id, facebook_user_id: "example")
|
||||
GithubUserInfo.create(user_id: source_user.id, screen_name: "example", github_user_id: "examplel123123")
|
||||
|
|
Loading…
Reference in New Issue
Block a user