about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-02-03 10:27:07 +0100
committerGitHub <noreply@github.com>2020-02-03 10:27:07 +0100
commit94cdbc4982bde9709a633d26ff9a083dd9661258 (patch)
tree66a2d3ef757eb5f7ed7b57a7dc215e77c0a18e97 /app/validators
parent4cd2d13bd226c005317adf9848f4c0316401b2ff (diff)
parent3dcb279da31bc7810b7f58991dad4f886aaade34 (diff)
Merge pull request #1274 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
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?