1
1
forked from 0ad/0ad

Update the rules for new lobby usernames

Right now usernames for the lobby can consist solely of numbers and
special characters. This can result in nonsensical usernames and is
prone to be abused. While we can't entirely prevent nonsensical
usernames, we can at least do a bit better.

Therefore, this adjusts the rules for the validation of new lobby
usernames in pyrogenesis. Previously these rules were:

- length: between 1 and 20 characters
- valid characters: lower- and uppercase letters, numbers, ".", "_", "-"

The new rules are:

- length: between 3 and 20 characters
- valid characters: lower- and uppercase letters, numbers, ".", "_", "-"
- must contain at least one letter

These validation changes are relevant for new user registrations only
and don't affect existing users. As this also just adjusts the
client-side validation, users will also still be able to register
usernames according to the old rules, e.g. when using an older version
of 0 A.D., until the same change gets rolled out at a later point in
time server-side as well.

This was SVN commit r27670.
This commit is contained in:
Dunedan 2023-06-08 15:21:04 +00:00
parent b131e641f5
commit 2a17a2866e

View File

@ -4,7 +4,7 @@ function checkUsername(register)
if (!username) if (!username)
return translate("Please enter your username"); return translate("Please enter your username");
if (register && (!username.match(/^[a-z0-9._-]*$/i) || username.length > 20)) if (register && !username.match(/^(?=.*[a-z])[a-z0-9._-]{3,20}$/i))
return translate("Invalid username"); return translate("Invalid username");
return ""; return "";