From 2fadce8ae14bf2f87b6753d5ecef7217617d3745 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Wed, 5 Apr 2023 21:02:49 +0800 Subject: [PATCH] improve checks for update user api --- server/src/controllers/auth.controller.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/controllers/auth.controller.ts b/server/src/controllers/auth.controller.ts index a1cb64a..a6bdbaf 100644 --- a/server/src/controllers/auth.controller.ts +++ b/server/src/controllers/auth.controller.ts @@ -239,6 +239,11 @@ export const updateUser = async (req: Request, res: Response) => { return; } + if (!req.body.name && !req.body.email && !req.body.password) { + res.status(400).end(); + return; + } + const name = xss(req.body.name || req.session.user.name); const pattern = /^[A-Za-z0-9]+$/; if (!pattern.test(name)) {