Browse Source

add system usernames validation

main
ghost 11 months ago
parent
commit
a8cbfffce2
  1. 2
      .env
  2. 12
      src/Controller/UserController.php

2
.env

@ -71,7 +71,7 @@ APP_MODERATOR_REMOTE_IP=
APP_ADD_USER_NAME_REGEX=/^[0-9A-z-]{2,16}$/ui APP_ADD_USER_NAME_REGEX=/^[0-9A-z-]{2,16}$/ui
# User name reserved (case insensitive) separated with | # User name reserved (case insensitive) separated with |
APP_ADD_USER_NAME_BLACKLIST=KevaChat|admin|moderator|anon|test APP_ADD_USER_NAME_BLACKLIST=KevaChat|admin|moderator|test
# Delay before have ability to create new username again # Delay before have ability to create new username again
APP_ADD_USER_REMOTE_IP_DELAY=86400 APP_ADD_USER_REMOTE_IP_DELAY=86400

12
src/Controller/UserController.php

@ -235,6 +235,18 @@ class UserController extends AbstractController
); );
} }
// Validate system username values
if (in_array(mb_strtolower($username), ['anon','anonymous']))
{
return $this->redirectToRoute(
'user_add',
[
'username' => $request->get('username'),
'error' => $translator->trans('Username reserved for anonymous users!')
]
);
}
// Validate meta NS // Validate meta NS
if (str_starts_with($username, '_')) if (str_starts_with($username, '_'))
{ {

Loading…
Cancel
Save