Skip to content

Commit

Permalink
Merge pull request bradtraversy#10 from rafasfz/master
Browse files Browse the repository at this point in the history
Added a validation on the single story route
  • Loading branch information
bradtraversy committed Sep 1, 2020
2 parents efe8ee5 + fd63c8e commit 1381a27
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions routes/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ router.get('/:id', ensureAuth, async (req, res) => {
return res.render('error/404')
}

res.render('stories/show', {
story,
})
if (story.user._id != req.user.id && story.status == 'private') {
res.render('error/404')
} else {
res.render('stories/show', {
story,
})
}
} catch (err) {
console.error(err)
res.render('error/404')
Expand Down

0 comments on commit 1381a27

Please sign in to comment.