Skip to content

Commit

Permalink
fix(server): resolve conflict for username in update user handler
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 10, 2024
1 parent 7dba7b9 commit 2002fc9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/handlers/auth/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down

0 comments on commit 2002fc9

Please sign in to comment.