FIX: Check for reserved usernames before hitting DB.

This commit is contained in:
Guo Xiang Tan 2017-04-13 11:32:20 +08:00
parent 57788200ec
commit 72c16967e6

View File

@ -162,7 +162,7 @@ class User < ActiveRecord::Base
def self.username_available?(username)
lower = username.downcase
!User.where(username_lower: lower).exists? && !reserved_username?(lower)
!reserved_username?(lower) && !User.where(username_lower: lower).exists?
end
def self.reserved_username?(username)