mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
Add support of allow free url config option with correspond modifications
This commit is contained in:
parent
4b7b902806
commit
5bb3de2675
3 changed files with 14 additions and 2 deletions
|
@ -112,7 +112,8 @@ function newNote(req, res, next) {
|
|||
return response.errorForbidden(res);
|
||||
}
|
||||
models.Note.create({
|
||||
ownerId: owner
|
||||
ownerId: owner,
|
||||
alias: req.alias ? req.alias : null
|
||||
}).then(function (note) {
|
||||
return res.redirect(config.serverurl + "/" + LZString.compressToBase64(note.id));
|
||||
}).catch(function (err) {
|
||||
|
@ -133,6 +134,7 @@ function checkViewPermission(req, note) {
|
|||
}
|
||||
|
||||
function findNote(req, res, callback, include) {
|
||||
var noteId = req.params.noteId;
|
||||
var id = req.params.noteId || req.params.shortid;
|
||||
models.Note.parseNoteId(id, function (err, _id) {
|
||||
models.Note.findOne({
|
||||
|
@ -142,7 +144,12 @@ function findNote(req, res, callback, include) {
|
|||
include: include || null
|
||||
}).then(function (note) {
|
||||
if (!note) {
|
||||
return response.errorNotFound(res);
|
||||
if (config.allowfreeurl && noteId) {
|
||||
req.alias = noteId;
|
||||
return newNote(req, res);
|
||||
} else {
|
||||
return response.errorNotFound(res);
|
||||
}
|
||||
}
|
||||
if (!checkViewPermission(req, note)) {
|
||||
return response.errorForbidden(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue