From ccb4ac11c0744fc23a34316adc13d2729c532249 Mon Sep 17 00:00:00 2001 From: xenis105 <xenis105@ajou.ac.kr> Date: Thu, 5 Dec 2024 00:02:51 +0900 Subject: [PATCH] recover --- controllers/TripController.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/controllers/TripController.js b/controllers/TripController.js index 88eab97..a67f1fd 100644 --- a/controllers/TripController.js +++ b/controllers/TripController.js @@ -64,23 +64,11 @@ const deleteTrip = async (req, res) => { // 공동 작업자 추가 const addCollaborator = async (req, res) => { try { - const { collaboratorEmail, collaboratorName } = req.body; - - let collaborator; - - if (collaboratorEmail) { - collaborator = await User.findOne({ email: collaboratorEmail }); - if (!collaborator) { - return res.status(404).json({ message: '해당 이메일의 사용자를 찾을 수 없습니다.' }); - } - } else if (collaboratorName) { - collaborator = await User.findOne({ name: collaboratorName }); - if (!collaborator) { - return res.status(404).json({ message: '해당 이름의 사용자를 찾을 수 없습니다.' }); - } - return res.status(200).json({ email: collaborator.email }); - } else { - return res.status(400).json({ message: '이메일 또는 이름을 제공해야 합니다.' }); + const { collaboratorEmail } = req.body; + + const collaborator = await User.findOne({ email: collaboratorEmail }); + if (!collaborator) { + return res.status(404).json({ message: '해당 이메일의 사용자를 찾을 수 없습니다.' }); } const trip = await Trip.findById(req.params.id).populate('create_by'); -- GitLab