Merge branch 'master' into glitch-soc/merge-upstream

This commit is contained in:
Thibaut Girka
2019-07-24 16:23:53 +02:00
11 changed files with 146 additions and 119 deletions

View File

@ -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?