]> cat aescling's git repositories - mastodon.git/commitdiff
Only check locally when deduplicating usernames (#13581)
authorkaiyou <pierre@jaury.eu>
Thu, 30 Apr 2020 12:39:05 +0000 (14:39 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2020 12:39:05 +0000 (14:39 +0200)
When deduplicating account usernames for OAuthable users, the routine did check if any account was known with that username, including remote accounts. This caused some unnecessary deduplication, and usernames ending with unexpected trailing _1.
This fixes #13580

app/models/concerns/omniauthable.rb

index 960784222702ce08deef9772048ab495b53d32f4..736da6c1ded4cc2e9384a6ea881e0f67c2747763 100644 (file)
@@ -82,7 +82,7 @@ module Omniauthable
       username = starting_username
       i        = 0
 
-      while Account.exists?(username: username)
+      while Account.exists?(username: username, domain: nil)
         i       += 1
         username = "#{starting_username}_#{i}"
       end