mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-29 07:53:02 +00:00
[API] Fix: Validate ids
This commit is contained in:
parent
2a6ac7e3ef
commit
564aa706bc
2 changed files with 10 additions and 0 deletions
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue