forbid del bookmarks for others

This commit is contained in:
luchenqun 2019-04-21 09:45:49 +08:00
parent c6dda1f4ba
commit 646b92285d
1 changed files with 12 additions and 1 deletions

View File

@ -312,7 +312,18 @@ api.delete('/delBookmark', function(req, res) {
return;
}
var bookmarkId = req.query.id;
db.delBookmarkTags(bookmarkId)
var userId = req.session.user.id;
db.getBookmark(bookmarkId)
.then((bookmark) => {
if(bookmark.user_id === userId) {
return db.delBookmarkTags(bookmarkId);
} else {
res.json({
result: 0
});
return Promise.reject("can not del others bookmark");
}
})
.then(() => db.delBookmark(bookmarkId))
.then((affectedRows) => res.json({
result: affectedRows