Don't add the shared folder to your drive is there is an access list

This commit is contained in:
yflory 2020-06-24 11:20:43 +02:00
parent bf8c43e9af
commit e25756ceca
5 changed files with 26 additions and 3 deletions

View File

@ -2083,6 +2083,9 @@ define([
Store.addSharedFolder = function (clientId, data, cb) {
var s = getStore(data.teamId);
s.manager.addSharedFolder(data, function (id) {
if (id && typeof(id) == "object" && id.error) {
return void cb(id);
}
var send = data.teamId ? s.sendEvent : sendDriveEvent;
send('DRIVE_CHANGE', {
path: ['drive', UserObject.FILES_DATA]

View File

@ -214,7 +214,7 @@ define([
if (!Env.folders[id]) { return {}; }
var obj = Env.folders[id].proxy.metadata || {};
for (var k in Env.user.proxy[UserObject.SHARED_FOLDERS][id] || {}) {
var data = JSON.parse(JSON.stringify(Env.user.proxy[UserObject.SHARED_FOLDERS][id][k]));
var data = JSON.parse(JSON.stringify(Env.user.proxy[UserObject.SHARED_FOLDERS][id][k] || {}));
if (k === "href" && data.indexOf('#') === -1) {
try {
data = Env.user.userObject.cryptor.decrypt(data);
@ -503,6 +503,17 @@ define([
};
if (data.password) { folderData.password = data.password; }
if (data.owned) { folderData.owners = [Env.edPublic]; }
}).nThen(function (waitFor) {
Env.Store.getPadMetadata(null, {
channel: folderData.channel
}, waitFor(function (obj) {
if (obj && (obj.error || obj.rejected)) {
waitFor.abort();
return void cb({
error: obj.error || 'ERESTRICTED'
});
}
}));
}).nThen(function (waitFor) {
Env.pinPads([folderData.channel], waitFor());
}).nThen(function (waitFor) {

View File

@ -363,7 +363,7 @@ define([
}
}).nThen(function (waitFor) {
if (cfg.afterSecrets) {
cfg.afterSecrets(Cryptpad, Utils, secret, waitFor());
cfg.afterSecrets(Cryptpad, Utils, secret, waitFor(), sframeChan);
}
}).nThen(function (waitFor) {
// Check if the pad exists on server

View File

@ -671,6 +671,10 @@ define([
UIElements.displayPasswordPrompt(funcs, cfg);
});
ctx.sframeChan.on("EV_RESTRICTED_ERROR", function () {
UI.errorLoadingScreen(Messages.restrictedError);
});
ctx.sframeChan.on("EV_PAD_PASSWORD_ERROR", function () {
UI.errorLoadingScreen(Messages.password_error_seed);
});

View File

@ -45,11 +45,16 @@ define([
};
window.addEventListener('message', onMsg);
}).nThen(function (/*waitFor*/) {
var afterSecrets = function (Cryptpad, Utils, secret, cb) {
var afterSecrets = function (Cryptpad, Utils, secret, cb, sframeChan) {
var _hash = hash.slice(1);
if (_hash && Utils.LocalStore.isLoggedIn()) {
// Add a shared folder!
Cryptpad.addSharedFolder(null, secret, function (id) {
if (id && typeof(id) === "object" && id.error) {
sframeChan.event("EV_RESTRICTED_ERROR");
return;
}
window.CryptPad_newSharedFolder = id;
// Clear the hash now that the secrets have been generated