summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-22 01:03:01 +0100
committerTor Andersson <tor@ccxvii.net>2023-12-23 02:10:40 +0100
commit56a7fa727280adcca16fd8460249d2dd49031689 (patch)
tree43566420465d092f52ccca20d3431a61d34bd68d
parentda5bc280b65c05d76a65083fd7b8dfd330e7acd3 (diff)
downloadserver-56a7fa727280adcca16fd8460249d2dd49031689.tar.gz
Add list of forbidden player names.
System reserved and easily confused names.
-rw-r--r--server.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/server.js b/server.js
index 3d58e09..5521c53 100644
--- a/server.js
+++ b/server.js
@@ -28,6 +28,8 @@ const LIMIT_ACTIVE_GAMES = (process.env.LIMIT_ACTIVE_GAMES | 0) || 29
const REGEX_MAIL = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
const REGEX_NAME = /^[\p{Alpha}\p{Number}'_-]+( [\p{Alpha}\p{Number}'_-]+)*$/u
+const FORBIDDEN_NAME = /^(Deleted|None|Draw|Both|All|null|admin)/i
+
const WEBHOOKS = process.env.WEBHOOKS | 0
if (WEBHOOKS)
console.log("Webhook notifications enabled.")
@@ -281,6 +283,8 @@ function is_valid_user_name(name) {
return false
if (name.length > 50)
return false
+ if (FORBIDDEN_NAME.test(name))
+ return false
return REGEX_NAME.test(name)
}