feat(config): allow restriction and disabling of uploads
Previously, image uploads were always allowed, unless `CMD_ALLOW_ANONYMOUS=false` and `CMD_ALLOW_ANONYMOUS_EDITS=false`. This PR adds a new config option `CMD_ENABLE_UPLOADS` to configure image uploads independently. There are three different modes: `all` (everyone can upload, guests too), `registered` (only registered and logged-in users can upload images), and `none` to completely disable image uploads. The default value is non-breaking as it is `all`, unless the config `CMD_ALLOW_ANONYMOUS=false` and `CMD_ALLOW_ANONYMOUS_EDITS=false` is set, in which case the value is `registered`. The UI will reflect the setting and either show or hide the upload button. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
@@ -79,6 +79,17 @@ if (!config.allowAnonymous && !config.allowAnonymousEdits) {
|
||||
if (!(config.defaultPermission in config.permission)) {
|
||||
config.defaultPermission = config.permission.editable
|
||||
}
|
||||
if (config.enableUploads === undefined) {
|
||||
if (!config.allowAnonymousEdits && !config.allowAnonymous) {
|
||||
config.enableUploads = 'registered'
|
||||
} else {
|
||||
config.enableUploads = 'all'
|
||||
}
|
||||
}
|
||||
if (!['all', 'registered', 'none'].includes(config.enableUploads)) {
|
||||
logger.error('Config option "enableUploads"/CMD_ENABLE_UPLOADS is not correctly set. Please use "all", "registered" or "none". Defaulting to "all"')
|
||||
config.enableUploads = 'all'
|
||||
}
|
||||
|
||||
// Use HTTPS protocol if the internal TLS server is enabled
|
||||
if (config.useSSL === true) {
|
||||
|
||||
Reference in New Issue
Block a user