Use username_min/max_length config keys in Model\User::create
This commit is contained in:
parent
2ed5c42cdd
commit
d360bf926a
|
@ -466,19 +466,23 @@ class User
|
|||
// collapse multiple spaces in name
|
||||
$username = preg_replace('/ +/', ' ', $username);
|
||||
|
||||
if (mb_strlen($username) > 48) {
|
||||
throw new Exception(L10n::t('Please use a shorter name.'));
|
||||
$username_min_length = max(1, min(255, intval(Config::get('system', 'username_min_length', 0))));
|
||||
$username_max_length = max(1, min(255, intval(Config::get('system', 'username_max_length', 0))));
|
||||
|
||||
if (mb_strlen($username) < $username_min_length) {
|
||||
throw new Exception(L10n::tt('Username should be at least %s character.', 'Username should be at least %s character.', $username_min_length));
|
||||
}
|
||||
if (mb_strlen($username) < 3) {
|
||||
throw new Exception(L10n::t('Name too short.'));
|
||||
|
||||
if (mb_strlen($username) > $username_max_length) {
|
||||
throw new Exception(L10n::tt('Username should be at most %s character.', 'Username should be at most %s characters.', $username_max_length));
|
||||
}
|
||||
|
||||
// So now we are just looking for a space in the full name.
|
||||
$loose_reg = Config::get('system', 'no_regfullname');
|
||||
if (!$loose_reg) {
|
||||
$username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
|
||||
if (!strpos($username, ' ')) {
|
||||
throw new Exception(L10n::t("That doesn't appear to be your full \x28First Last\x29 name."));
|
||||
if (strpos($username, ' ') === false) {
|
||||
throw new Exception(L10n::t("That doesn't appear to be your full (First Last) name."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue