Mittwoch, 18. Mai, 2016
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Finishing Angular TODO application and deploying to production 114<br />
53<br />
54 req.todo = todo;<br />
55 next();<br />
56 });<br />
57 };<br />
58<br />
59 exports.update = function(req, res) {<br />
60 var todo = req.todo;<br />
61 todo.title = req.body.title;<br />
62 todo.comment = req.body.comment;<br />
63 todo.completed = req.body.completed;<br />
64<br />
65 todo.save(function(err) {<br />
66 if (err) {<br />
67 return res.status(400).send({<br />
68 message: getErrorMessage(err)<br />
69 });<br />
70 } else {<br />
71 res.json(todo);<br />
72 }<br />
73 });<br />
74 };<br />
75<br />
76 exports.delete = function(req, res) {<br />
77 var todo = req.todo;<br />
78 todo.remove(function(err) {<br />
79 if (err) {<br />
80 return res.status(400).send({<br />
81 message: getErrorMessage(err)<br />
82 });<br />
83 } else {<br />
84 res.json(todo);<br />
85 }<br />
86 });<br />
87 };<br />
88<br />
89 exports.hasAuthorization = function(req, res, next) {<br />
90 if (req.todo.creator.id !== req.user.id) {<br />
91 return res.status(403).send({<br />
92 message: 'User is not authorized'<br />
93 });<br />
94 }