summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNV2017-02-10 11:46:10 +0900
committerNV2017-02-10 11:46:10 +0900
commit5375fe57790152bf97958bb54cef922f03b2b40e (patch)
tree99735a785e142839d4e5540d7addddc3886bcf71
parent0a7adaf35d07efa658c040e789967acdc2eb32ff (diff)
Add validation to defaultpermission in config
Diffstat (limited to '')
-rw-r--r--lib/config.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/config.js b/lib/config.js
index 052a5d0d..bdc2cbdb 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -24,8 +24,13 @@ 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;
+var permissions = ['editable', 'limited', 'locked', 'protected', 'private'];
+if (allowanonymous) {
+ permissions.unshift('freely');
+}
+
+var defaultpermission = process.env.HMD_DEFAULT_PERMISSION || config.defaultpermission;
+defaultpermission = permissions.indexOf(defaultpermission) != -1 ? defaultpermission : 'editable';
// db
var dburl = config.dburl || process.env.HMD_DB_URL || process.env.DATABASE_URL;