mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-13 18:45:43 +05:00
Move accounts config to plugin
This commit is contained in:
parent
6a96595020
commit
fcb829c88b
@ -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(); }
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user