user deletions: fix rename conflict logic.

Remove the 10-try limit when there's a name conflict during renaming. We
forgot to increment the loop counter so this did nothing. This wasn't
necessary anyway since the loop will always terminate eventually because
names have finite length.
This commit is contained in:
evazion
2020-04-03 23:30:48 -05:00
parent 300b8bdefc
commit 53b761dfe9

View File

@@ -50,12 +50,7 @@ class UserDeletion
def rename
name = "user_#{user.id}"
n = 0
name += "~" while User.where(:name => name).exists? && (n < 10)
if n == 10
raise ValidationError.new("New name could not be found")
end
name += "~" while User.exists?(name: name)
request = UserNameChangeRequest.new(user: user, desired_name: name, original_name: user.name)
request.save!(validate: false) # XXX don't validate so that the 1 name change per week rule doesn't interfere