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( ...@@ -33,7 +33,12 @@ accountsRouter.get(
//update account //update account
accountsRouter.patch( accountsRouter.patch(
"/api/accounts/:id/", "/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, validateToken,
accountsControllers.updateAccount accountsControllers.updateAccount
); );
......
...@@ -6,20 +6,21 @@ import { body } from "express-validator"; ...@@ -6,20 +6,21 @@ import { body } from "express-validator";
const userRouter = Router(); const userRouter = Router();
//show current user
userRouter.get( userRouter.get(
"/api/user/", "/api/user/",
validateToken, validateToken,
userControllers.showCurrentUserController userControllers.showCurrentUserController
); );
//update current user
userRouter.patch( userRouter.patch(
"/api/user/", "/api/user/",
body("first_name").not().isEmpty(), body("first_name").if(body("first_name").exists()).not().isEmpty(),
body("last_name").not().isEmpty(), body("last_name").if(body("last_name").exists()).not().isEmpty(),
body("email").isEmail().normalizeEmail(), body("email").if(body("email").exists()).isEmail().normalizeEmail(),
body("role").isIn(["coordinator", "boatManager"]), body("password").if(body("password").exists()).isLength({ min: 6 }),
body("password").isLength({ min: 6 }),
handleValidationResult, handleValidationResult,
validateToken, validateToken,
userControllers.updateCurrentUser 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