Skip to content

Commit

Permalink
#62 Fix issue on user deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Nov 23, 2020
1 parent c2582f9 commit 31423fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pages/api/user/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ const handler = async (req, res) => {
if (role === 'admin') {
const doc = await db
.collection('users')
.findOneAndDelete({ _id: ObjectID(req.query.id) });
.findOneAndDelete({ _id: ObjectID(req.query.id) })
.then(() => db
.collection('accounts')
.findOneAndDelete({ userId: ObjectID(req.query.id) }));
res.status(200).json(doc);
} else res.status(403).end('Unauthorized');
} else res.status(404).end('Not Found');
Expand Down

0 comments on commit 31423fd

Please sign in to comment.