store subdomain in database instead of fqdn
this makes it more consistent with the locations table
This commit is contained in:
+11
-10
@@ -33,23 +33,24 @@ const apps = require('./apps.js'),
|
||||
|
||||
async function getLocation() {
|
||||
const domain = await settings.get(settings.DASHBOARD_DOMAIN_KEY) || '';
|
||||
const fqdn = await settings.get(settings.DASHBOARD_FQDN_KEY) || '';
|
||||
const subdomain = await settings.get(settings.DASHBOARD_SUBDOMAIN_KEY) || '';
|
||||
const fqdn = domain ? dns.fqdn(subdomain, domain) : '';
|
||||
|
||||
return { domain, fqdn, subdomain: fqdn ? constants.DASHBOARD_SUBDOMAIN : '' };
|
||||
return { subdomain, domain, fqdn };
|
||||
}
|
||||
|
||||
async function setLocation(domain) {
|
||||
async function setLocation(subdomain, domain) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
|
||||
const fqdn = domain ? dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domain) : '';
|
||||
await settings.set(settings.DASHBOARD_SUBDOMAIN_KEY, subdomain);
|
||||
await settings.set(settings.DASHBOARD_DOMAIN_KEY, domain);
|
||||
await settings.set(settings.DASHBOARD_FQDN_KEY, fqdn);
|
||||
|
||||
debug(`setLocation: ${domain || '<cleared>'}`);
|
||||
}
|
||||
|
||||
async function clearLocation() {
|
||||
await setLocation('');
|
||||
await setLocation('', '');
|
||||
}
|
||||
|
||||
async function getConfig() {
|
||||
@@ -110,7 +111,8 @@ async function prepareLocation(subdomain, domain, auditSource, progressCallback)
|
||||
await reverseProxy.ensureCertificate(location, {}, auditSource);
|
||||
}
|
||||
|
||||
async function setupLocation(domain, auditSource) {
|
||||
async function setupLocation(subdomain, domain, auditSource) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
@@ -119,14 +121,13 @@ async function setupLocation(domain, auditSource) {
|
||||
if (constants.DEMO) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode');
|
||||
|
||||
await reverseProxy.writeDashboardConfig(domain);
|
||||
const fqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domain);
|
||||
|
||||
const currentLocation = await getLocation();
|
||||
await setLocation(domain);
|
||||
await setLocation(subdomain, domain);
|
||||
if (!currentLocation.domain) return; // first time location is set, no change notification needed
|
||||
|
||||
debug('setupLocation: notifying platform of domain change');
|
||||
await eventlog.add(eventlog.ACTION_DASHBOARD_DOMAIN_UPDATE, auditSource, { domain, fqdn });
|
||||
await eventlog.add(eventlog.ACTION_DASHBOARD_DOMAIN_UPDATE, auditSource, { subdomain, domain });
|
||||
await safe(appstore.updateCloudron({ domain }), { debug });
|
||||
await platform.onDashboardLocationChanged(auditSource);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user