make changeDashboardDomain customizable
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#
|
#
|
||||||
# domains:
|
# domains:
|
||||||
# dynamicDns: true
|
# dynamicDns: true
|
||||||
|
# changeDashboardDomain: true
|
||||||
#
|
#
|
||||||
# subscription:
|
# subscription:
|
||||||
# configurable: true
|
# configurable: true
|
||||||
|
|||||||
+2
-1
@@ -17,7 +17,8 @@ const DEFAULT_SPEC = {
|
|||||||
configurable: true
|
configurable: true
|
||||||
},
|
},
|
||||||
domains: {
|
domains: {
|
||||||
dynamicDns: true
|
dynamicDns: true,
|
||||||
|
changeDashboardDomain: true
|
||||||
},
|
},
|
||||||
subscription: {
|
subscription: {
|
||||||
configurable: true
|
configurable: true
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ let assert = require('assert'),
|
|||||||
auditSource = require('../auditsource.js'),
|
auditSource = require('../auditsource.js'),
|
||||||
cloudron = require('../cloudron.js'),
|
cloudron = require('../cloudron.js'),
|
||||||
CloudronError = cloudron.CloudronError,
|
CloudronError = cloudron.CloudronError,
|
||||||
|
custom = require('../custom.js'),
|
||||||
HttpError = require('connect-lastmile').HttpError,
|
HttpError = require('connect-lastmile').HttpError,
|
||||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||||
updater = require('../updater.js'),
|
updater = require('../updater.js'),
|
||||||
@@ -152,6 +153,8 @@ function getLogStream(req, res, next) {
|
|||||||
function setDashboardAndMailDomain(req, res, next) {
|
function setDashboardAndMailDomain(req, res, next) {
|
||||||
if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
||||||
|
|
||||||
|
if (!custom.spec().domains.changeDashboardDomain) return next(new HttpError(405, 'feature disabled by admin'));
|
||||||
|
|
||||||
cloudron.setDashboardAndMailDomain(req.body.domain, auditSource.fromRequest(req), function (error) {
|
cloudron.setDashboardAndMailDomain(req.body.domain, auditSource.fromRequest(req), function (error) {
|
||||||
if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
|
if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
|
||||||
if (error) return next(new HttpError(500, error));
|
if (error) return next(new HttpError(500, error));
|
||||||
@@ -163,6 +166,8 @@ function setDashboardAndMailDomain(req, res, next) {
|
|||||||
function prepareDashboardDomain(req, res, next) {
|
function prepareDashboardDomain(req, res, next) {
|
||||||
if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
||||||
|
|
||||||
|
if (!custom.spec().domains.changeDashboardDomain) return next(new HttpError(405, 'feature disabled by admin'));
|
||||||
|
|
||||||
cloudron.prepareDashboardDomain(req.body.domain, auditSource.fromRequest(req), function (error, taskId) {
|
cloudron.prepareDashboardDomain(req.body.domain, auditSource.fromRequest(req), function (error, taskId) {
|
||||||
if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
|
if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
|
||||||
if (error && error.reason === CloudronError.BAD_STATE) return next(new HttpError(409, error.message));
|
if (error && error.reason === CloudronError.BAD_STATE) return next(new HttpError(409, error.message));
|
||||||
|
|||||||
Reference in New Issue
Block a user