[+] Limit user creation

pull/17/head
Azalea 2024-03-01 00:30:37 -05:00
parent 8f9f9e9e82
commit 3efbefe4c5
1 changed files with 4 additions and 0 deletions

View File

@ -117,6 +117,10 @@ class AquaUserServices(
if (length > 32) 400 - "Username too long (max 32 letters)" if (length > 32) 400 - "Username too long (max 32 letters)"
if (contains(" ")) 400 - "Username cannot contain spaces" if (contains(" ")) 400 - "Username cannot contain spaces"
// card{id} is a reserved format
if (startsWith("card") && substring(4).toLongOrNull() != null)
400 - "Username cannot be 'card' + a number. This format is reserved for card IDs."
// Check if username is within A-Za-z0-9_-~. // Check if username is within A-Za-z0-9_-~.
find { !it.isLetterOrDigit() && it != '_' && it != '-' && it != '~' && it != '.' }?.let { find { !it.isLetterOrDigit() && it != '_' && it != '-' && it != '~' && it != '.' }?.let {
400 - "Username cannot contain `$it`. Please only use letters (A-Z), numbers (0-9), and `_-~.` characters. You can set a display name later." 400 - "Username cannot contain `$it`. Please only use letters (A-Z), numbers (0-9), and `_-~.` characters. You can set a display name later."