Update: Ad.findAll add userId
This commit is contained in:
parent
b66ea1f929
commit
d220a68f3d
1 changed files with 10 additions and 1 deletions
|
|
@ -57,7 +57,16 @@ exports.findAll = (req, res) => {
|
|||
condition = adId ? adId : undefined;
|
||||
query._id = condition;
|
||||
|
||||
const userId = req.query.userId;
|
||||
let userId;
|
||||
if(typeof token.role !== 'undefined' &&
|
||||
typeof token.role.permission !== 'undefined' &&
|
||||
typeof token.role.isAccepted !== 'undefined' &&
|
||||
token.role.isAccepted === true &&
|
||||
token.role.permission >= roles.Admin.permission) {
|
||||
userId = req.query.userId;
|
||||
} else {
|
||||
userId = token.id;
|
||||
}
|
||||
condition = userId ? userId : undefined;
|
||||
query.userId = condition;
|
||||
|
||||
|
|
|
|||
Reference in a new issue