Fixed a problem with the update of a user

This commit is contained in:
Tiago Ribeiro
2024-10-17 08:45:18 +01:00
parent 9f1f564e25
commit 532b49165c

View File

@@ -79,6 +79,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
let user = await db.collection("users").findOne<User>({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});