Skip to content
Snippets Groups Projects
Commit 4dcd32ba authored by alrwasheda's avatar alrwasheda :speech_balloon:
Browse files

Merge branch '21-implement-api-endpoints' of...

Merge branch '21-implement-api-endpoints' of git.imp.fu-berlin.de:swp-ws21-fahrtenbuch/team-einhorn/fahrtenbuch into 21-implement-api-endpoints
parents 3333dac4 60a31af1
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,12 @@ accountsRouter.get(
//update account
accountsRouter.patch(
"/api/accounts/:id/",
handleValidationResult, //!! not working here
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("role").if(body("role").exists()).isIn(["coordinator", "boatManager"]),
body("password").if(body("password").exists()).isLength({ min: 6 }),
handleValidationResult,
validateToken,
accountsControllers.updateAccount
);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment