diff options
| author | Adam Soltys <[email protected]> | 2025-09-30 13:55:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-09-30 13:55:08 -0700 |
| commit | 5061e32b32d26c55fe854f9c1635e827449b2871 (patch) | |
| tree | 754284fdeddea12bb929cb2636f69e662aa39030 | |
| parent | 481dec5b1cfa2a085dda500ce0c390b38cb4a8b0 (diff) | |
| download | coinos-server-5061e32b32d26c55fe854f9c1635e827449b2871.tar.gz coinos-server-5061e32b32d26c55fe854f9c1635e827449b2871.zip | |
fix username change logic
| -rw-r--r-- | routes/users.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/routes/users.ts b/routes/users.ts index 7b9a486b..e3810d70 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -241,17 +241,17 @@ export default { if (username) { const currentUsername = user.username.replace(/\s/g, "").toLowerCase(); - exists = await db.exists(`user:${currentUsername}`); + if (username !== currentUsername) { + exists = await db.exists(`user:${username}`); - if (currentUsername !== username && exists) { - err("username taken", username, currentUsername); - fail("Username taken"); - } else if (username) { - if (currentUsername !== username) + if (exists) { + err("username taken", username, currentUsername); + fail("Username taken"); + } else { l("changing username", currentUsername, username); - - await db.del(`user:${currentUsername}`); - user.username = username; + await db.del(`user:${currentUsername}`); + user.username = username; + } } } |
