Disallow dnsSetup if domain already set

This commit is contained in:
Girish Ramakrishnan
2017-01-05 17:17:47 -08:00
committed by Johannes Zellner
parent 0b68d1c9aa
commit 09997398b1
2 changed files with 5 additions and 12 deletions
+4 -11
View File
@@ -90,20 +90,13 @@ function dnsSetup(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider is required'));
if (config.fqdn()) return next(new HttpError(409, 'Already setup'));
if (config.provider() === 'caas') return next(new HttpError(410, 'Not availabe for caas'));
// check if already activated
user.count(function (error, count) {
settings.setDnsConfig(req.body, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return next(new HttpError(400, error.message));
if (error) return next(new HttpError(500, error));
if (count > 0) return next(new HttpError(409, 'Already setup'));
settings.setDnsConfig(req.body, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return next(new HttpError(400, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200));
});
next(new HttpSuccess(200));
});
}