[API] Fix: Validate id
This commit is contained in:
		
							parent
							
								
									46e85e5cc3
								
							
						
					
					
						commit
						2f596948f3
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -33,6 +33,11 @@ module.exports = (params, me) =>
 | 
			
		|||
		return rej('user_id or username is required');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Validate id
 | 
			
		||||
	if (userId && !mongo.ObjectID.isValid(userId)) {
 | 
			
		||||
		return rej('incorrect user_id');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Lookup user
 | 
			
		||||
	const user = userId !== null
 | 
			
		||||
		? await User.findOne({ _id: new mongo.ObjectID(userId) })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue