aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-09-30 13:55:08 -0700
committerAdam Soltys <[email protected]>2025-09-30 13:55:08 -0700
commit5061e32b32d26c55fe854f9c1635e827449b2871 (patch)
tree754284fdeddea12bb929cb2636f69e662aa39030
parent481dec5b1cfa2a085dda500ce0c390b38cb4a8b0 (diff)
downloadcoinos-server-5061e32b32d26c55fe854f9c1635e827449b2871.tar.gz
coinos-server-5061e32b32d26c55fe854f9c1635e827449b2871.zip
fix username change logic
-rw-r--r--routes/users.ts18
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;
+ }
}
}