diff --git a/lib/commands/quota.js b/lib/commands/quota.js index 6fb33bee3..c4ec46422 100644 --- a/lib/commands/quota.js +++ b/lib/commands/quota.js @@ -196,7 +196,6 @@ Quota.shouldContactServer = function (Env) { ( typeof(Env.blockDailyCheck) === 'undefined' && Env.adminEmail === false - && Env.allowSubscriptions === false ) ); }; @@ -225,22 +224,23 @@ var queryQuotaServer = function (Env, cb) { } }; + const accountsOrigin = Env.plugins?.ACCOUNTS?.getConfig()?.accountsOrigin; var H = Https; - if (typeof(Env.accounts_api) === 'string') { + if (typeof(accountsOrigin) === 'string') { try { - let url = new URL(Env.accounts_api); + let url = new URL(accountsOrigin); if (!['https:', 'http:'].includes(url.protocol)) { throw new Error("INVALID_PROTOCOL"); } if (url.protocol === 'http:') { H = Http; } let port = Number(url.port); if (port && typeof(port) === 'number') { options.port = port; } options.host = url.hostname; Env.Log.info("USING_CUSTOM_ACCOUNTS_API", { - value: Env.accounts_api, + value: accountsOrigin, }); } catch (err) { Env.Log.error("INVALID_CUSTOM_QUOTA_API", { error: err.message, - value: Env.accounts_api, + value: accountsOrigin, }); } } @@ -284,7 +284,7 @@ Quota.updateCachedLimits = function (Env, _cb) { Quota.applyCustomLimits(Env); - if (!Env.allowSubscriptions || !Env.accounts_api) { return void cb(); } + if (!Env.plugins?.ACCOUNTS) { return void cb(); } Quota.queryQuotaServer(Env, function (err, json) { if (err) { return void cb(err); } if (!json) { return void cb(); } diff --git a/lib/env.js b/lib/env.js index 737355ede..81fb1300f 100644 --- a/lib/env.js +++ b/lib/env.js @@ -103,7 +103,8 @@ module.exports.create = function (config) { httpSafePort: httpSafePort, websocketPort: config.websocketPort, - accounts_api: config.accounts_api || undefined, // this simplifies integration with an accounts page + // XXX TODO + accounts_api: plugins?.ACCOUNTS?.getConfig()?.accountsOrigin, shouldUpdateNode: !isRecentVersion(), @@ -212,7 +213,6 @@ module.exports.create = function (config) { See also the cached 'restrictRegistration' value in server.js#serveConfig */ restrictRegistration: false, - allowSubscriptions: config.allowSubscriptions === true, blockDailyCheck: config.blockDailyCheck === true, consentToContact: false, diff --git a/lib/http-worker.js b/lib/http-worker.js index ac435260a..982dd7bb1 100644 --- a/lib/http-worker.js +++ b/lib/http-worker.js @@ -611,7 +611,8 @@ var serveConfig = makeRouteCache(function () { urlArgs: 'ver=' + Env.version + cacheString(), }, removeDonateButton: (Env.removeDonateButton === true), - allowSubscriptions: (Env.allowSubscriptions === true), + allowSubscriptions: Boolean(Env.accounts_api), + accounts_api: Env.accounts_api, websocketPath: Env.websocketPath, httpUnsafeOrigin: Env.httpUnsafeOrigin, adminEmail: Env.adminEmail, @@ -631,7 +632,6 @@ var serveConfig = makeRouteCache(function () { fileHost: Env.fileHost, shouldUpdateNode: Env.shouldUpdateNode || undefined, listMyInstance: Env.listMyInstance, - accounts_api: Env.accounts_api, sso: ssoCfg, enforceMFA: Env.enforceMFA, onlyOffice: Env.onlyOffice diff --git a/www/checkup/main.js b/www/checkup/main.js index 051c53c9f..9519a0165 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -82,7 +82,7 @@ define([ var trimmedSafe = trimSlashes(ApiConfig.httpSafeOrigin); var trimmedUnsafe = trimSlashes(ApiConfig.httpUnsafeOrigin); var fileHost = ApiConfig.fileHost; - var accounts_api = ApiConfig.accounts_api || AppConfig.accounts_api || undefined; + var accounts_api = ApiConfig.accounts_api || undefined; var getAPIPlaceholderPath = function (relative) { var absolute;