Add default permission config
This commit is contained in:
parent
a0d16eec23
commit
0a7adaf35d
2 changed files with 6 additions and 2 deletions
|
@ -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 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
|
// db
|
||||||
var dburl = config.dburl || process.env.HMD_DB_URL || process.env.DATABASE_URL;
|
var dburl = config.dburl || process.env.HMD_DB_URL || process.env.DATABASE_URL;
|
||||||
var db = config.db || {};
|
var db = config.db || {};
|
||||||
|
@ -173,6 +176,7 @@ module.exports = {
|
||||||
usecdn: usecdn,
|
usecdn: usecdn,
|
||||||
allowanonymous: allowanonymous,
|
allowanonymous: allowanonymous,
|
||||||
allowfreeurl: allowfreeurl,
|
allowfreeurl: allowfreeurl,
|
||||||
|
defaultpermission: defaultpermission,
|
||||||
dburl: dburl,
|
dburl: dburl,
|
||||||
db: db,
|
db: db,
|
||||||
sslkeypath: path.join(cwd, sslkeypath),
|
sslkeypath: path.join(cwd, sslkeypath),
|
||||||
|
|
|
@ -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.permission) {
|
||||||
if (note.ownerId) {
|
if (note.ownerId) {
|
||||||
note.permission = "editable";
|
note.permission = config.defaultpermission;
|
||||||
} else {
|
} else {
|
||||||
note.permission = "freely";
|
note.permission = "freely";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue