initial features implementation

This commit is contained in:
Girish Ramakrishnan
2019-05-07 09:34:23 -07:00
parent 0cf523c285
commit 33d5cb3061
11 changed files with 125 additions and 71 deletions

View File

@@ -9,6 +9,7 @@ exports = module.exports = {
var assert = require('assert'),
backups = require('../backups.js'),
custom = require('../custom.js'),
docker = require('../docker.js'),
DockerError = docker.DockerError,
HttpError = require('connect-lastmile').HttpError,
@@ -130,6 +131,11 @@ function getBackupConfig(req, res, next) {
settings.getBackupConfig(function (error, config) {
if (error) return next(new HttpError(500, error));
// used by the UI to figure if backups are disabled
if (!custom.features().configureBackup) {
return next(new HttpSuccess(200, { provider: config.provider }));
}
next(new HttpSuccess(200, backups.removePrivateFields(config)));
});
}
@@ -137,6 +143,8 @@ function getBackupConfig(req, res, next) {
function setBackupConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (!custom.features().configureBackup) return next(new HttpError(403, 'feature disabled by admin'));
if (typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider is required'));
if (typeof req.body.retentionSecs !== 'number') return next(new HttpError(400, 'retentionSecs is required'));
if (typeof req.body.intervalSecs !== 'number') return next(new HttpError(400, 'intervalSecs is required'));
@@ -199,6 +207,8 @@ function getDynamicDnsConfig(req, res, next) {
function setDynamicDnsConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (!custom.features().dynamicDns) return next(new HttpError(403, 'feature disabled by admin'));
if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled boolean is required'));
settings.setDynamicDnsConfig(req.body.enabled, function (error) {