diff --git a/.eslintignore b/.eslintignore index 2ba68a9ee..d96e7c3b7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,7 +15,7 @@ www/accounts www/worker www/todo -lib/plugins/ +#lib/plugins/ www/common/hyperscript.js diff --git a/customize.dist/login.js b/customize.dist/login.js index 870736a33..349e69145 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -22,11 +22,13 @@ define([ '/common/outer/login-block.js', '/common/common-hash.js', '/common/outer/http-command.js', + '/api/config', '/components/tweetnacl/nacl-fast.min.js', '/components/scrypt-async/scrypt-async.min.js', // better load speed ], function ($, Listmap, Crypto, Util, NetConfig, Login, Cred, ChainPad, Realtime, Constants, UI, - Feedback, h, LocalStore, Messages, nThen, Block, Hash, ServerCommand) { + Feedback, h, LocalStore, Messages, nThen, Block, Hash, ServerCommand, + ApiConfig) { var Exports = { Cred: Cred, Block: Block, @@ -218,6 +220,11 @@ define([ proxy.edPublic = result.edPublic; } + if (ApiConfig && Array.isArray(ApiConfig.adminKeys) && + ApiConfig.adminKeys.includes(proxy.edPublic)) { + localStorage.CP_admin = "1"; + } + setTimeout(function () { Realtime.whenRealtimeSyncs(result.realtime, function () { proceed(result); diff --git a/customize.dist/pages/index.js b/customize.dist/pages/index.js index 27d510961..3b919643f 100644 --- a/customize.dist/pages/index.js +++ b/customize.dist/pages/index.js @@ -168,6 +168,7 @@ define([ let popup = h('div.cp-extensions-popups'); let utils = { h, Util, Hash }; Extensions.getExtensions('HOMEPAGE_POPUP').forEach(ext => { + if (typeof(ext.check) === "function" && !ext.check()) { return; } ext.getContent(utils, content => { $(popup).append(h('div.cp-extensions-popup', content)); }); diff --git a/lib/http-worker.js b/lib/http-worker.js index 6822496c4..b118d6ef8 100644 --- a/lib/http-worker.js +++ b/lib/http-worker.js @@ -652,7 +652,7 @@ define(paths, function () { return args; }, function () { // ignore missing files -});` +});`; app.get('/extensions.js', (req, res) => { res.setHeader('Content-Type', 'text/javascript'); res.send(js); @@ -752,7 +752,7 @@ app.post('/api/auth', function (req, res, next) { }); app.use(function (req, res /*, next */) { - if (/^(\/favicon\.ico\/|.*\.js\.map|.*\/translations\/.*\.json)$/.test(req.url)) { + if (/^(\/favicon\.ico\/|.*\.js\.map|.*\/translations\/.*\.json)/.test(req.url)) { // ignore common 404s } else { Log.info('HTTP_404', req.url); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index ed69a18db..4525c8287 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2822,6 +2822,15 @@ define([ initFeedback(data.feedback); } + if (data.edPublic) { + if (Array.isArray(Config.adminKeys) && + Config.adminKeys.includes(data.edPublic)) { + // Doesn't provides extra-rights but may show + // additional warnings in the UI + localStorage.CP_admin = "1"; + } + } + if (data.loggedIn) { window.CP_logged_in = true; } diff --git a/www/common/extensions.js b/www/common/extensions.js index cfd2ca39e..134c71113 100644 --- a/www/common/extensions.js +++ b/www/common/extensions.js @@ -15,7 +15,14 @@ define([ let defaultLang = current[1]; let lang = current[2]; if (!Object.keys(lang).length && Object.keys(defaultLang).length) { + // If our language doesn't exists, use default lang = defaultLang; + } else if (Object.keys(defaultLang).length) { + // Otherwise fill our language with missing keys + Object.keys(defaultLang).forEach(key => { + if (typeof(lang[key]) !== "undefined") { return; } + lang[key] = defaultLang[key]; + }); } lang._getKey = function (key, argArray) { diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index cd93675fe..029a15f74 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -3014,6 +3014,8 @@ define([ // Make sure we have a valid user object before emitting cacheready if (rt.proxy && !rt.proxy.drive) { return; } + returned.edPublic = rt.proxy.edPublic; + onCacheReady(clientId, function () { if (typeof(cb) === "function") { cb(returned); } onCacheReadyEvt.fire(); @@ -3047,6 +3049,8 @@ define([ drive[Constants.oldStorageKey] = []; } */ + + returned.edPublic = rt.proxy.edPublic; // Drive already exist: return the existing drive, don't load data from legacy store if (store.manager) { // If a cache is loading, make sure it is complete before calling onReady diff --git a/www/install/main.js b/www/install/main.js index fffb7343d..24a15ec16 100644 --- a/www/install/main.js +++ b/www/install/main.js @@ -145,6 +145,7 @@ define([ edPublic: proxy.edPublic }, function (e) { if (e) { UI.alert(Messages.error); return console.error(e); } + localStorage.CP_admin = "1"; window.location.href = '/drive/'; }); });