mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-15 15:36:30 +00:00
Merge pull request #926 from hedgedoc/1.x/note-nonexistent-404
Add HTTP 404 error on actions for non-existent notes
This commit is contained in:
commit
090d4178d9
2 changed files with 6 additions and 3 deletions
|
@ -119,7 +119,7 @@ exports.doAction = function (req, res, next) {
|
|||
default:
|
||||
return res.redirect(config.serverURL + '/' + noteId)
|
||||
}
|
||||
})
|
||||
}, null, false)
|
||||
}
|
||||
|
||||
exports.downloadMarkdown = function (req, res, note) {
|
||||
|
|
|
@ -5,7 +5,7 @@ const errors = require('../../errors')
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
exports.findNote = function (req, res, callback, include) {
|
||||
exports.findNote = function (req, res, callback, include, createIfNotFound = true) {
|
||||
const id = req.params.noteId || req.params.shortid
|
||||
models.Note.parseNoteId(id, function (err, _id) {
|
||||
if (err) {
|
||||
|
@ -18,9 +18,12 @@ exports.findNote = function (req, res, callback, include) {
|
|||
},
|
||||
include: include || null
|
||||
}).then(function (note) {
|
||||
if (!note) {
|
||||
if (!note && createIfNotFound) {
|
||||
return exports.newNote(req, res, '')
|
||||
}
|
||||
if (!note && !createIfNotFound) {
|
||||
return errors.errorNotFound(res)
|
||||
}
|
||||
if (!exports.checkViewPermission(req, note)) {
|
||||
return errors.errorForbidden(res)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue