fix: page broken when shortId doesn't exists

Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
BoHong Li 2020-02-26 10:23:46 +08:00
parent 05dd6eb739
commit db615e5111
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
1 changed files with 4 additions and 4 deletions

View File

@ -94,14 +94,14 @@ async function showPublishNote (req, res) {
includeUser: true includeUser: true
}) })
if (!canViewNote(note, req.isAuthenticated(), req.user ? req.user.id : null)) {
return errorForbidden(req)
}
if (!note) { if (!note) {
return errorNotFound(res) return errorNotFound(res)
} }
if (!canViewNote(note, req.isAuthenticated(), req.user ? req.user.id : null)) {
return errorForbidden(req)
}
if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) { if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) {
return res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid)) return res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid))
} }