[API] Fix: Validate ids

This commit is contained in:
syuilo 2017-01-18 05:26:29 +09:00
parent be25c2f88e
commit b4cd456a2a
2 changed files with 10 additions and 0 deletions

View file

@ -28,6 +28,11 @@ module.exports = (params, user) =>
return rej('user_id is required');
}
// Validate id
if (!mongo.ObjectID.isValid(userId)) {
return rej('incorrect user_id');
}
// 自分自身
if (user._id.equals(userId)) {
return rej('followee is yourself');

View file

@ -27,6 +27,11 @@ module.exports = (params, user) =>
return rej('user_id is required');
}
// Validate id
if (!mongo.ObjectID.isValid(userId)) {
return rej('incorrect user_id');
}
// Check if the followee is yourself
if (user._id.equals(userId)) {
return rej('followee is yourself');