[API] Fix: Validate ids
This commit is contained in:
parent
2a6ac7e3ef
commit
564aa706bc
@ -28,6 +28,11 @@ module.exports = (params, user) =>
|
|||||||
return rej('user_id is required');
|
return rej('user_id is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate id
|
||||||
|
if (!mongo.ObjectID.isValid(userId)) {
|
||||||
|
return rej('incorrect user_id');
|
||||||
|
}
|
||||||
|
|
||||||
// 自分自身
|
// 自分自身
|
||||||
if (user._id.equals(userId)) {
|
if (user._id.equals(userId)) {
|
||||||
return rej('followee is yourself');
|
return rej('followee is yourself');
|
||||||
|
@ -27,6 +27,11 @@ module.exports = (params, user) =>
|
|||||||
return rej('user_id is required');
|
return rej('user_id is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate id
|
||||||
|
if (!mongo.ObjectID.isValid(userId)) {
|
||||||
|
return rej('incorrect user_id');
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the followee is yourself
|
// Check if the followee is yourself
|
||||||
if (user._id.equals(userId)) {
|
if (user._id.equals(userId)) {
|
||||||
return rej('followee is yourself');
|
return rej('followee is yourself');
|
||||||
|
Loading…
Reference in New Issue
Block a user