58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
exports = module.exports = {
|
|
getLocation,
|
|
setLocation,
|
|
|
|
getConfig,
|
|
};
|
|
|
|
const appstore = require('./appstore.js'),
|
|
assert = require('assert'),
|
|
branding = require('./branding.js'),
|
|
constants = require('./constants.js'),
|
|
mailServer = require('./mailserver.js'),
|
|
settings = require('./settings.js'),
|
|
system = require('./system.js'),
|
|
users = require('./users.js');
|
|
|
|
async function setLocation(domain, fqdn) {
|
|
assert.strictEqual(typeof domain, 'string');
|
|
assert.strictEqual(typeof fqdn, 'string');
|
|
|
|
// should probably be just one key. or make this a transaction
|
|
await settings.set(settings.DASHBOARD_DOMAIN_KEY, domain);
|
|
await settings.set(settings.DASHBOARD_FQDN_KEY, fqdn);
|
|
}
|
|
|
|
async function getLocation() {
|
|
const domain = await settings.get(settings.DASHBOARD_DOMAIN_KEY) || '';
|
|
const fqdn = await settings.get(settings.DASHBOARD_FQDN_KEY) || '';
|
|
|
|
return { domain, fqdn, subdomain: constants.DASHBOARD_SUBDOMAIN };
|
|
}
|
|
|
|
async function getConfig() {
|
|
const ubuntuVersion = await system.getUbuntuVersion();
|
|
const profileConfig = await users.getProfileConfig();
|
|
const { fqdn:adminFqdn, domain:adminDomain } = await getLocation();
|
|
|
|
// be picky about what we send out here since this is sent for 'normal' users as well
|
|
return {
|
|
apiServerOrigin: await appstore.getApiServerOrigin(),
|
|
webServerOrigin: await appstore.getWebServerOrigin(),
|
|
consoleServerOrigin: await appstore.getConsoleServerOrigin(),
|
|
adminDomain,
|
|
adminFqdn,
|
|
mailFqdn: await mailServer.getLocation().fqdn,
|
|
version: constants.VERSION,
|
|
ubuntuVersion,
|
|
isDemo: constants.DEMO,
|
|
cloudronName: await branding.getCloudronName(),
|
|
footer: await branding.renderFooter(),
|
|
features: appstore.getFeatures(),
|
|
profileLocked: profileConfig.lockUserProfiles,
|
|
mandatory2FA: profileConfig.mandatory2FA,
|
|
};
|
|
}
|