From 532b49165ce84a074bf0830fba5c0111c1392154 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Thu, 17 Oct 2024 08:45:18 +0100 Subject: [PATCH] Fixed a problem with the update of a user --- src/pages/api/users/update.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/api/users/update.ts b/src/pages/api/users/update.ts index 681cca55..9ba975f2 100644 --- a/src/pages/api/users/update.ts +++ b/src/pages/api/users/update.ts @@ -79,6 +79,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { let user = await db.collection("users").findOne({id: queryId ? (queryId as string) : req.session.user.id}); const updatedUser = req.body as User & {password?: string; newPassword?: string}; + delete (updatedUser as any)._id if (!!queryId) { await db.collection("users").updateOne({id: queryId}, {$set: updatedUser});