Skip to content

Commit

Permalink
fix: incorrect query of findOne in delete user
Browse files Browse the repository at this point in the history
- It's req.user.user, the user is changed to object
  • Loading branch information
Chinlinlee committed Jun 5, 2022
1 parent 198a599 commit 5d4ab36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/login/api/users/controller/delete_user.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const mongodb = require('models/mongodb');
const _ = require("lodash");

module.exports = async function (req, res)
{
const _id = req.params._id;
try {
let user = await mongodb.users.findOne({account : req.user});
let username = _.get(req, "user.user");
let user = await mongodb.users.findOne({ account: username });
if (user.usertype.toUpperCase() != "ADMIN") {
return res.status(400).send("Not Allow");
}
Expand All @@ -20,6 +22,7 @@ module.exports = async function (req, res)
}
});
} catch (e) {
console.error(e);
return res.status(500).json(e.message);
}
}

0 comments on commit 5d4ab36

Please sign in to comment.