[API] Fix: Validate id
This commit is contained in:
		
							parent
							
								
									225c89a5b8
								
							
						
					
					
						commit
						8b3e371733
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		|  | @ -23,6 +23,11 @@ module.exports = (params, user) => | ||||||
| 		return rej('post_id is required'); | 		return rej('post_id is required'); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	// Validate id
 | ||||||
|  | 	if (!mongo.ObjectID.isValid(postId)) { | ||||||
|  | 		return rej('incorrect post_id'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	// Get post
 | 	// Get post
 | ||||||
| 	const post = await Post.findOne({ | 	const post = await Post.findOne({ | ||||||
| 		_id: new mongo.ObjectID(postId) | 		_id: new mongo.ObjectID(postId) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue