Add support of allow anonymous config option with correspond modifications
This commit is contained in:
@@ -60,6 +60,7 @@ function showIndex(req, res, next) {
|
||||
res.render(config.indexpath, {
|
||||
url: config.serverurl,
|
||||
useCDN: config.usecdn,
|
||||
allowAnonmyous: config.allowanonmyous,
|
||||
facebook: config.facebook,
|
||||
twitter: config.twitter,
|
||||
github: config.github,
|
||||
@@ -92,6 +93,7 @@ function responseHackMD(res, note) {
|
||||
url: config.serverurl,
|
||||
title: title,
|
||||
useCDN: config.usecdn,
|
||||
allowAnonmyous: config.allowanonmyous,
|
||||
facebook: config.facebook,
|
||||
twitter: config.twitter,
|
||||
github: config.github,
|
||||
@@ -106,6 +108,8 @@ function newNote(req, res, next) {
|
||||
var owner = null;
|
||||
if (req.isAuthenticated()) {
|
||||
owner = req.user.id;
|
||||
} else if (!config.allowanonmyous) {
|
||||
return response.errorForbidden(res);
|
||||
}
|
||||
models.Note.create({
|
||||
ownerId: owner
|
||||
|
||||
Reference in New Issue
Block a user