Minor refactoring of freeURL condition check

Signed-off-by: Nicolas Dietrich <nidi@mailbox.org>
This commit is contained in:
Nicolas Dietrich 2021-01-22 15:36:47 +01:00
parent ea52746104
commit 3331c0947c

View file

@ -51,10 +51,12 @@ exports.newNote = function (req, res, body) {
} else if (!config.allowAnonymous) { } else if (!config.allowAnonymous) {
return errors.errorForbidden(res) return errors.errorForbidden(res)
} }
if (config.allowFreeURL && noteId && !config.forbiddenNoteIDs.includes(noteId)) { if (noteId) {
req.alias = noteId if (config.allowFreeURL && !config.forbiddenNoteIDs.includes(noteId)) {
} else if (noteId) { req.alias = noteId
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res) } else {
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
}
} }
models.Note.create({ models.Note.create({
ownerId: owner, ownerId: owner,