about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-05-04 14:22:04 +0200
committerGitHub <noreply@github.com>2021-05-04 14:22:04 +0200
commit3639862dee7e47cfd4f11430871aae3f3f71821f (patch)
tree8a3c2e2f5cf0bea06ba88d47faf90f4896242fb8
parentfab65848d2eb8065ef3e49aaca4e4fb33f94f2b1 (diff)
Fix existing username validator not allowing multiple accounts (#16153)
Fix #16107
-rw-r--r--app/validators/existing_username_validator.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/validators/existing_username_validator.rb b/app/validators/existing_username_validator.rb
index afbe0c635..8f7d96b8e 100644
--- a/app/validators/existing_username_validator.rb
+++ b/app/validators/existing_username_validator.rb
@@ -19,10 +19,10 @@ class ExistingUsernameValidator < ActiveModel::EachValidator
       str unless Account.find_remote(username, domain)
     end
 
-    if usernames_with_no_accounts.any? && options[:multiple]
-      record.errors.add(attribute, I18n.t('existing_username_validator.not_found_multiple', usernames: usernames_with_no_accounts.join(', ')))
-    elsif usernames_with_no_accounts.any? || usernames_and_domains.size > 1
-      record.errors.add(attribute, I18n.t('existing_username_validator.not_found'))
+    if options[:multiple]
+      record.errors.add(attribute, I18n.t('existing_username_validator.not_found_multiple', usernames: usernames_with_no_accounts.join(', '))) if usernames_with_no_accounts.any?
+    else
+      record.errors.add(attribute, I18n.t('existing_username_validator.not_found')) if usernames_with_no_accounts.any? || usernames_and_domains.size > 1
     end
   end
 end