diff --git a/src/controllers/userProfileController.js b/src/controllers/userProfileController.js index c57a656ac..db1dc671c 100644 --- a/src/controllers/userProfileController.js +++ b/src/controllers/userProfileController.js @@ -1797,6 +1797,21 @@ const userProfileController = function (UserProfile, Project) { } }; + const updateUserInformation = async function (req,res){ + try { + const data=req.body; + data.map(async (e)=> { + let result = await UserProfile.findById(e.user_id); + result[e.item]=e.value + let newdata=await result.save() + }) + res.status(200).send({ message: 'Update successful'}); + } catch (error) { + console.log(error) + return res.status(500) + } + } + return { postUserProfile, getUserProfiles, @@ -1825,7 +1840,8 @@ const userProfileController = function (UserProfile, Project) { getProjectsByPerson, getAllTeamCode, getAllTeamCodeHelper, - getUserProfileBasicInfo, + updateUserInformation, + getUserProfileBasicInfo }; }; diff --git a/src/routes/userProfileRouter.js b/src/routes/userProfileRouter.js index 3e86c5837..73bc2ac5b 100644 --- a/src/routes/userProfileRouter.js +++ b/src/routes/userProfileRouter.js @@ -23,9 +23,9 @@ const routes = function (userProfile, project) { controller.postUserProfile, ); + userProfileRouter.route('/userProfile/update').patch(controller.updateUserInformation); // Endpoint to retrieve basic user profile information userProfileRouter.route('/userProfile/basicInfo').get(controller.getUserProfileBasicInfo); - userProfileRouter .route('/userProfile/:userId') .get(controller.getUserById)