From d73b32a05edc71823974226c1e839da3e45fc3bc Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 9 Mar 2020 12:12:29 +0100 Subject: [PATCH] Make sure users can't block themselves with SF allow list --- www/common/outer/async-store.js | 1 + www/common/outer/sharedfolder.js | 12 ++++++++++++ www/common/proxy-manager.js | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index e87f2cc97..a1f939e56 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -78,6 +78,7 @@ define([ Realtime.whenRealtimeSyncs(s.realtime, waitFor()); if (s.sharedFolders && typeof (s.sharedFolders) === "object") { for (var k in s.sharedFolders) { + if (!s.sharedFolders[k].realtime) { continue; } // Deprecated Realtime.whenRealtimeSyncs(s.sharedFolders[k].realtime, waitFor()); } } diff --git a/www/common/outer/sharedfolder.js b/www/common/outer/sharedfolder.js index 907c49cd0..cbeae1cbd 100644 --- a/www/common/outer/sharedfolder.js +++ b/www/common/outer/sharedfolder.js @@ -214,6 +214,18 @@ define([ }); } catch (e) {} delete allSharedFolders[secret.channel]; + // This shouldn't be called on init because we're calling "isNewChannel" first, + // but we can still call "cb" just in case. This wait we make sure we won't block + // the initial "waitFor" + return void cb(); + } + if (info.error === "ERESTRICTED" ) { + // This shouldn't happen: allow list are disabled for shared folders + // but call "cb" to make sure we won't block the initial "waitFor" + sf.teams.forEach(function (obj) { + obj.store.manager.restrictedProxy(obj.id, secret.channel); + }); + return void cb(); } } }); diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index 29f762956..d13f242fc 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -67,6 +67,13 @@ define([ } }; + var restrictedProxy = function (Env, id, channel) { + var lm = { proxy: { deprecated: true } }; + removeProxy(Env, id); + addProxy(Env, id, lm, function () {}); + return void Env.Store.refreshDriveUI(); + }; + /* Tools */ @@ -1118,6 +1125,7 @@ define([ addProxy: callWithEnv(addProxy), removeProxy: callWithEnv(removeProxy), deprecateProxy: callWithEnv(deprecateProxy), + restrictedProxy: callWithEnv(restrictedProxy), addSharedFolder: callWithEnv(_addSharedFolder), // Drive command: callWithEnv(onCommand),