diff options
author | Reverite <github@reverite.sh> | 2019-07-24 12:10:59 -0700 |
---|---|---|
committer | Reverite <github@reverite.sh> | 2019-07-24 12:10:59 -0700 |
commit | 2282fcc060109b41a540a7c46b8411c095488dcf (patch) | |
tree | 72a35aa40b8de52481cfd7ecfbccef00e7d66d7a /app/validators | |
parent | fee3abd1dce8f437e3514cb03816ae50862b3c4c (diff) | |
parent | 88e79c179a1a48feff3b16226c46f5885442651e (diff) |
Merge branch 'glitch' into production
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/unique_username_validator.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/validators/unique_username_validator.rb b/app/validators/unique_username_validator.rb index fb67105dd..4e24e3f5f 100644 --- a/app/validators/unique_username_validator.rb +++ b/app/validators/unique_username_validator.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true +# See also: USERNAME_RE in the Account class + class UniqueUsernameValidator < ActiveModel::Validator def validate(account) return if account.username.nil? - normalized_username = account.username.downcase.delete('.') + normalized_username = account.username.downcase scope = Account.where(domain: nil).where('lower(username) = ?', normalized_username) scope = scope.where.not(id: account.id) if account.persisted? |