aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-03-23 00:49:26 -0700
committerAdam Soltys <[email protected]>2024-03-23 00:49:30 -0700
commit6f31e8c4dff2897eaf07d1ed5519972e63827462 (patch)
tree6ac74ffefb69fd7d137e36cbade227fc08c96f4f /lib
parent5fe1fc6ed3cee0e01d0aa732f8c5b6a9c47e93f1 (diff)
downloadcoinos-server-6f31e8c4dff2897eaf07d1ed5519972e63827462.tar.gz
coinos-server-6f31e8c4dff2897eaf07d1ed5519972e63827462.zip
validate usernames
Diffstat (limited to 'lib')
-rw-r--r--lib/register.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/register.js b/lib/register.js
index b43a0ce7..f6f0ff75 100644
--- a/lib/register.js
+++ b/lib/register.js
@@ -9,13 +9,15 @@ import { s, g, archive } from "$lib/db";
import { l, warn } from "$lib/logging";
import { fail, getUser } from "$lib/utils";
+let valid = /^\p{L}{2,24}$/u;
export default async (user, ip, requireChallenge) => {
let { profile, password, pubkey, username } = user;
l("registering", username);
if (!username) fail("Username required");
-
username = username.replace(/ /g, "").toLowerCase();
+ if (!valid.test(username)) fail("Usernames can only have letters and numbers");
+
let id = v4();
user.id = id;