ENCOA-202: Fixed issue updating user
This commit is contained in:
@@ -77,7 +77,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
const queryId = req.query.id as string;
|
||||
|
||||
let user = await db.collection("users").findOne<User>({ id: queryId ? (queryId as string) : req.session.user.id });
|
||||
const userId = queryId ? (queryId as string) : req.session.user.id
|
||||
let user = await db.collection("users").findOne<User>({ id: userId });
|
||||
const updatedUser = req.body as User & { password?: string; newPassword?: string };
|
||||
|
||||
if (!!queryId) {
|
||||
@@ -160,7 +161,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
delete updatedUser.newPassword;
|
||||
|
||||
await db.collection("users").updateOne(
|
||||
{ id: queryId },
|
||||
{ id: userId },
|
||||
{ $set: updatedUser }
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user