From 60a31af154698036d64ee335aca8deacc486cf96 Mon Sep 17 00:00:00 2001 From: Irakli Maisuradze <mysuradze@gmail.com> Date: Sun, 16 Jan 2022 02:33:16 +0100 Subject: [PATCH] fixed update info/user route --- server/src/routes/user.routes.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/routes/user.routes.ts b/server/src/routes/user.routes.ts index 5e0f3b7..3da97ed 100644 --- a/server/src/routes/user.routes.ts +++ b/server/src/routes/user.routes.ts @@ -6,20 +6,21 @@ import { body } from "express-validator"; const userRouter = Router(); - +//show current user userRouter.get( "/api/user/", validateToken, userControllers.showCurrentUserController ); + +//update current user userRouter.patch( "/api/user/", - body("first_name").not().isEmpty(), - body("last_name").not().isEmpty(), - body("email").isEmail().normalizeEmail(), - body("role").isIn(["coordinator", "boatManager"]), - body("password").isLength({ min: 6 }), + body("first_name").if(body("first_name").exists()).not().isEmpty(), + body("last_name").if(body("last_name").exists()).not().isEmpty(), + body("email").if(body("email").exists()).isEmail().normalizeEmail(), + body("password").if(body("password").exists()).isLength({ min: 6 }), handleValidationResult, validateToken, userControllers.updateCurrentUser -- GitLab