From 2002fc97d2621f0a464ff6e2abef6ed9d32ad9d1 Mon Sep 17 00:00:00 2001 From: lareii Date: Tue, 10 Sep 2024 15:41:22 +0300 Subject: [PATCH] fix(server): resolve conflict for username in update user handler --- server/handlers/auth/update.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/handlers/auth/update.go b/server/handlers/auth/update.go index 7fb10c3..b4d5445 100644 --- a/server/handlers/auth/update.go +++ b/server/handlers/auth/update.go @@ -43,11 +43,13 @@ func UpdateUser(c *fiber.Ctx) error { "message": "Error checking if user exists.", }) } - if checkUser.Username != "" { + + if checkUser.Username != "" && body.Username != user.Username { return c.Status(fiber.StatusConflict).JSON(fiber.Map{ "message": "Username already exists.", }) } + update["$set"].(bson.M)["username"] = body.Username } if body.Password != "" {