Skip to content

Commit f4bcf62

Browse files
author
Helga
committed
[fix] filtering out not allowed formdata fields for put operations
1 parent 0929101 commit f4bcf62

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ app.delete("/events/:id", (req, res, next) => {
153153
});
154154

155155
app.post("/events", (req, res, next) => {
156-
db.insert(req.body, (err, data) => {
156+
const event = {};
157+
for (f in req.body){
158+
if (allowedFields.indexOf(f) !== -1) event[f] = req.body[f];
159+
}
160+
161+
db.insert(event, (err, data) => {
157162
if (err)
158163
next(err);
159164
else

0 commit comments

Comments
 (0)