Add support for username regex.

This commit is contained in:
Bianca Nenciu
2017-02-27 22:28:56 +02:00
parent fdf749770b
commit 30909ec54e
4 changed files with 23 additions and 3 deletions

View File

@@ -162,7 +162,7 @@ class User < ActiveRecord::Base
lower = username.downcase
User.where(username_lower: lower).blank? &&
!SiteSetting.reserved_usernames.split("|").any? { |reserved| reserved.casecmp(username) == 0 }
SiteSetting.reserved_usernames.split("|").all? { |reserved| !lower.match('^' + Regexp.escape(reserved).gsub('\*', '.*') + '$') }
end
def self.plugin_staff_user_custom_fields