mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't try to rename group when username is taken
FIX: Always rename groups with the default locale instead of using the user's locale
This commit is contained in:
@@ -220,7 +220,7 @@ class User < ActiveRecord::Base
|
||||
def self.username_available?(username, email = nil, allow_reserved_username: false)
|
||||
lower = username.downcase
|
||||
return false if !allow_reserved_username && reserved_username?(lower)
|
||||
return true if DB.exec(User::USERNAME_EXISTS_SQL, username: lower) == 0
|
||||
return true if !username_exists?(lower)
|
||||
|
||||
# staged users can use the same username since they will take over the account
|
||||
email.present? && User.joins(:user_emails).exists?(staged: true, username_lower: lower, user_emails: { primary: true, email: email })
|
||||
@@ -1271,6 +1271,10 @@ class User < ActiveRecord::Base
|
||||
WHERE lower(groups.name) = :username)
|
||||
SQL
|
||||
|
||||
def self.username_exists?(username_lower)
|
||||
DB.exec(User::USERNAME_EXISTS_SQL, username: username_lower) > 0
|
||||
end
|
||||
|
||||
def username_validator
|
||||
username_format_validator || begin
|
||||
lower = username.downcase
|
||||
|
Reference in New Issue
Block a user