Skip to content

Commit

Permalink
Merge pull request #17 from WE-thing/feat/user-api
Browse files Browse the repository at this point in the history
feat: 유저 업데이트 로직변경
  • Loading branch information
OneK-2 authored May 31, 2024
2 parents e8af4d9 + 52d7dcc commit a63168d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions routes/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ async function authenticate(req, res, next) {
const user = verifyToken(headerToken);
req.user = user;
next();
}
else req.user = null;
} else req.user = null;
}

async function loginRequired(req, res, next) {
Expand Down Expand Up @@ -92,12 +91,16 @@ router.get("/:id", async (req, res) => {
}
});

router.put("/:id", async (req, res) => {
router.put("/:userName/:phoneNumber", async (req, res) => {
try {
const user = await User.findOneAndUpdate({ id: req.params.id }, req.body, {
new: true,
runValidators: true,
});
const user = await User.findOneAndUpdate(
{ name: req.params.name, phoneNumber: req.params.phoneNumber },
req.body,
{
new: true,
runValidators: true,
}
);
if (!user) {
return res.status(404).json({ message: "user not found" });
}
Expand Down

0 comments on commit a63168d

Please sign in to comment.