[ticket/16013] Allow admins to use disallowed username

PHPBB3-16013
This commit is contained in:
Jakub Senko 2019-05-24 15:17:18 +02:00
parent f6beabc593
commit 2b1102e372
No known key found for this signature in database
GPG key ID: 6A7C328CD66EC21E
2 changed files with 10 additions and 7 deletions

View file

@ -855,7 +855,7 @@ class acp_users
$check_ary += array( $check_ary += array(
'username' => array( 'username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('string', false, $config['min_name_chars'], $config['max_name_chars']),
array('username', $user_row['username']) array('username', $user_row['username'], true)
), ),
); );
} }

View file

@ -1732,7 +1732,7 @@ function phpbb_validate_timezone($timezone)
* @return mixed Either false if validation succeeded or a string which will be * @return mixed Either false if validation succeeded or a string which will be
* used as the error message (with the variable name appended) * used as the error message (with the variable name appended)
*/ */
function validate_username($username, $allowed_username = false) function validate_username($username, $allowed_username = false, $allow_all_names = false)
{ {
global $config, $db, $user, $cache; global $config, $db, $user, $cache;
@ -1815,13 +1815,16 @@ function validate_username($username, $allowed_username = false)
return 'USERNAME_TAKEN'; return 'USERNAME_TAKEN';
} }
$bad_usernames = $cache->obtain_disallowed_usernames(); if (!$allow_all_names)
foreach ($bad_usernames as $bad_username)
{ {
if (preg_match('#^' . $bad_username . '$#', $clean_username)) $bad_usernames = $cache->obtain_disallowed_usernames();
foreach ($bad_usernames as $bad_username)
{ {
return 'USERNAME_DISALLOWED'; if (preg_match('#^' . $bad_username . '$#', $clean_username))
{
return 'USERNAME_DISALLOWED';
}
} }
} }