Fix bug where cloudron cannot be setup if initial dns credentials were invalid

To reproduce:
* https://ip
* provide invalid dns creds. at this point, config.fqdn gets set already
* cannot setup anymore
This commit is contained in:
Girish Ramakrishnan
2017-01-12 11:08:34 -08:00
parent d6ea7fc3a0
commit 44742ea3ae

View File

@@ -198,7 +198,9 @@ function syncConfigState(callback) {
isConfigured(function (error, configured) {
if (error) return callback(error);
debug('syncConfigState: configured = %s', configured);
debug('syncConfigState: configured = %s already configured = %s', configured, gConfigState.configured);
if (gConfigState.configured) return callback(); // required because we call syncConfigState directly from dnsSetup
if (configured) {
gConfigState.configured = true;
@@ -217,12 +219,13 @@ function dnsSetup(dnsConfig, domain, callback) {
if (config.fqdn()) return callback(new CloudronError(CloudronError.ALREADY_SETUP));
config.set('fqdn', domain); // set fqdn only after dns config is valid, otherwise cannot re-setup if we failed
settings.setDnsConfig(dnsConfig, domain, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return callback(new CloudronError(CloudronError.BAD_FIELD, error.message));
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
config.set('fqdn', domain); // set fqdn only after dns config is valid, otherwise cannot re-setup if we failed
syncConfigState();
callback();
});
}