User/Auth

* use char limit appropriate to current auth method, when checking usernames
This commit is contained in:
Sarjuuk
2016-03-29 21:16:16 +02:00
parent b84854d4ba
commit a521935934

View File

@@ -367,7 +367,21 @@ class User
{ {
$errCode = 0; $errCode = 0;
if (mb_strlen($name) < 4 || mb_strlen($name) > 16) // different auth modes require different usernames
$min = 0; // external case
$max = 0;
if (CFG_ACC_AUTH_MODE == AUTH_MODE_SELF)
{
$min = 4;
$max = 16;
}
else if (CFG_ACC_AUTH_MODE == AUTH_MODE_REALM)
{
$min = 3;
$max = 32;
}
if (($min && mb_strlen($name) < $min) || ($max && mb_strlen($name) > $max))
$errCode = 1; $errCode = 1;
else if (preg_match('/[^\w\d\-]/i', $name)) else if (preg_match('/[^\w\d\-]/i', $name))
$errCode = 2; $errCode = 2;