MCPcopy Create free account
hub / github.com/dhatGuy/PERN-Store / updateUser

Function updateUser

server/controllers/users.controller.js:48–68  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

46};
47
48const updateUser = async (req, res) => {
49 const { username, email, fullname, address, city, state, country } = req.body;
50 if (+req.params.id === req.user.id || req.user.roles.includes("admin")) {
51 try {
52 const results = await userService.updateUser({
53 username,
54 email,
55 fullname,
56 address,
57 city,
58 state,
59 country,
60 id: req.params.id,
61 });
62 return res.status(201).json(results);
63 } catch (error) {
64 throw new ErrorHandler(error.statusCode, error.message);
65 }
66 }
67 throw new ErrorHandler(401, "Unauthorized");
68};
69
70const deleteUser = async (req, res) => {
71 const { id } = req.params;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected