diff --git a/lib/response.js b/lib/response.js index 41e8c33647..9381d40559 100644 --- a/lib/response.js +++ b/lib/response.js @@ -51,7 +51,9 @@ function responseError (res, code, detail, msg) { code: code, detail: detail, msg: msg, - useCDN: config.usecdn + useCDN: config.usecdn, + allowAnonymousEdits: false, + signin: false }) } @@ -80,7 +82,7 @@ function showIndex (req, res, next) { }) } -function responseHackMD (res, note) { +function responseHackMD (req, res, note) { var body = note.content var extracted = models.Note.extractMeta(body) var meta = models.Note.parseMeta(extracted.meta) @@ -108,6 +110,7 @@ function responseHackMD (res, note) { saml: config.isSAMLEnable, email: config.isEmailEnable, allowemailregister: config.allowemailregister, + signin: req.isAuthenticated(), allowpdfexport: config.allowpdfexport }) } @@ -116,7 +119,7 @@ function newNote (req, res, next) { var owner = null if (req.isAuthenticated()) { owner = req.user.id - } else if (!config.allowanonymous) { + } else if (!config.allowanonymousedits) { return response.errorForbidden(res) } models.Note.create({ @@ -181,7 +184,7 @@ function showNote (req, res, next) { var noteId = req.params.noteId var id = LZString.compressToBase64(note.id) if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) { return res.redirect(config.serverurl + '/' + (note.alias || id)) } - return responseHackMD(res, note) + return responseHackMD(req, res, note) }) } @@ -215,6 +218,8 @@ function showPublishNote (req, res, next) { var data = { title: title, description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), + allowAnonymousEdits: config.allowanonymousedits, + signin: req.isAuthenticated(), viewcount: note.viewcount, createtime: createtime, updatetime: updatetime, diff --git a/public/views/hackmd/header.ejs b/public/views/hackmd/header.ejs index b87f21fa3d..27fdd18e73 100644 --- a/public/views/hackmd/header.ejs +++ b/public/views/hackmd/header.ejs @@ -22,10 +22,12 @@