about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-02-03 09:22:58 +0100
committerThibaut Girka <thib@sitedethib.com>2020-02-03 09:22:58 +0100
commit369201a425f7b539290815402a4bc65923911e11 (patch)
tree45de36cd6aa8c22aaf4be6cefaeeb70218d4daf5 /app/validators
parent4cd2d13bd226c005317adf9848f4c0316401b2ff (diff)
parent3adc722d1cdd28d87d2724b8952d7ec52d241b52 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/unique_username_validator.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/validators/unique_username_validator.rb b/app/validators/unique_username_validator.rb
index 4e24e3f5f..f87eb06ba 100644
--- a/app/validators/unique_username_validator.rb
+++ b/app/validators/unique_username_validator.rb
@@ -7,8 +7,9 @@ class UniqueUsernameValidator < ActiveModel::Validator
     return if account.username.nil?
 
     normalized_username = account.username.downcase
+    normalized_domain = account.domain&.downcase
 
-    scope = Account.where(domain: nil).where('lower(username) = ?', normalized_username)
+    scope = Account.where(Account.arel_table[:username].lower.eq normalized_username).where(Account.arel_table[:domain].lower.eq normalized_domain)
     scope = scope.where.not(id: account.id) if account.persisted?
 
     account.errors.add(:username, :taken) if scope.exists?