summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNV2017-02-09 13:24:40 +0900
committerNV2017-02-10 10:16:38 +0900
commit0a7adaf35d07efa658c040e789967acdc2eb32ff (patch)
treed8860bf9fe78ca9d48114ed22e36150f7cdb8313 /lib
parenta0d16eec2340aacb8cfaa83070500395bfd50672 (diff)
Add default permission config
Diffstat (limited to '')
-rw-r--r--lib/config.js4
-rw-r--r--lib/models/note.js4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/config.js b/lib/config.js
index c0373820..052a5d0d 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -24,6 +24,9 @@ var allowanonymous = process.env.HMD_ALLOW_ANONYMOUS ? (process.env.HMD_ALLOW_AN
var allowfreeurl = process.env.HMD_ALLOW_FREEURL ? (process.env.HMD_ALLOW_FREEURL === 'true') : !!config.allowfreeurl;
+var defaultpermission = process.env.HMD_DEFAULT_PERMISSION || config.defaultpermission || 'editable';
+defaultpermission = (!allowanonymous && defaultpermission == 'freely') ? 'editable' : defaultpermission;
+
// db
var dburl = config.dburl || process.env.HMD_DB_URL || process.env.DATABASE_URL;
var db = config.db || {};
@@ -173,6 +176,7 @@ module.exports = {
usecdn: usecdn,
allowanonymous: allowanonymous,
allowfreeurl: allowfreeurl,
+ defaultpermission: defaultpermission,
dburl: dburl,
db: db,
sslkeypath: path.join(cwd, sslkeypath),
diff --git a/lib/models/note.js b/lib/models/note.js
index 86112973..8b38d3f9 100644
--- a/lib/models/note.js
+++ b/lib/models/note.js
@@ -513,10 +513,10 @@ module.exports = function (sequelize, DataTypes) {
}
}
}
- // if no permission specified and have owner then give editable permission, else default permission is freely
+ // if no permission specified and have owner then give default permission in config, else default permission is freely
if (!note.permission) {
if (note.ownerId) {
- note.permission = "editable";
+ note.permission = config.defaultpermission;
} else {
note.permission = "freely";
}