diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-01-21 07:46:43 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-01-21 07:46:43 +0900 |
| commit | 8b3e3717335025b41a56d4190791294c5ae936f3 (patch) | |
| tree | bd7d005a18ba6158cff67ca3316d8c971d592ad6 /src/api/endpoints/posts | |
| parent | [API] Fix bug (diff) | |
| download | sharkey-8b3e3717335025b41a56d4190791294c5ae936f3.tar.gz sharkey-8b3e3717335025b41a56d4190791294c5ae936f3.tar.bz2 sharkey-8b3e3717335025b41a56d4190791294c5ae936f3.zip | |
[API] Fix: Validate id
Diffstat (limited to 'src/api/endpoints/posts')
| -rw-r--r-- | src/api/endpoints/posts/show.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/api/endpoints/posts/show.js b/src/api/endpoints/posts/show.js index 19cdb74251..f399d86c8a 100644 --- a/src/api/endpoints/posts/show.js +++ b/src/api/endpoints/posts/show.js @@ -23,6 +23,11 @@ module.exports = (params, user) => return rej('post_id is required'); } + // Validate id + if (!mongo.ObjectID.isValid(postId)) { + return rej('incorrect post_id'); + } + // Get post const post = await Post.findOne({ _id: new mongo.ObjectID(postId) |