Make the verifyDnsConfig() api return the valid credentials

This commit is contained in:
Johannes Zellner
2017-01-10 11:32:44 +01:00
parent badbb89c92
commit babfb5efbb
7 changed files with 46 additions and 16 deletions
+7 -2
View File
@@ -179,16 +179,21 @@ function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var credentials = {
provider: dnsConfig.provider,
token: dnsConfig.token
};
dns.resolveNs(domain, function (error, nameservers) {
if (error && error.code === 'ENOTFOUND') return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Unable to resolve nameservers for this domain'));
if (error || !nameservers) return callback(error || new Error('Unable to get nameservers'));
upsert(dnsConfig, domain, 'my', 'A', [ ip ], function (error, changeId) {
upsert(credentials, domain, 'my', 'A', [ ip ], function (error, changeId) {
if (error) return callback(new SubdomainError(SubdomainError.INTERNAL_ERROR, error));
debug('verifyDnsConfig: A record added with change id %s', changeId);
callback();
callback(null, credentials);
});
});
}