Skip to content

Commit

Permalink
Merge pull request #306 from openstad/bugfix/deleting-article-with-re…
Browse files Browse the repository at this point in the history
…source-btn

Added auth.useReqUser to route delete on article
  • Loading branch information
LorenzoJokhan authored Jun 12, 2023
2 parents 456a875 + 66b9746 commit b067e05
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/routes/api/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ router.route('/:articleId(\\d+)')

// delete article
// ---------
.delete(auth.can('Article', 'delete'))
.delete(auth.useReqUser)
.delete(function(req, res, next) {
req.results
const article = req.results;
if (!(article && article.can && article.can('delete'))) return next(new Error('You cannot delete this article'));

article
.destroy()
.then(() => {
res.json({ "article": "deleted" });
Expand Down

1 comment on commit b067e05

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published new image: openstad/api:devel-b067e05

Please sign in to comment.