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

pull/1/head
yflory 4 years ago
parent bf8c43e9af
commit e25756ceca

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

@ -214,7 +214,7 @@ define([
if (!Env.folders[id]) { return {}; } if (!Env.folders[id]) { return {}; }
var obj = Env.folders[id].proxy.metadata || {}; var obj = Env.folders[id].proxy.metadata || {};
for (var k in Env.user.proxy[UserObject.SHARED_FOLDERS][id] || {}) { 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) { if (k === "href" && data.indexOf('#') === -1) {
try { try {
data = Env.user.userObject.cryptor.decrypt(data); data = Env.user.userObject.cryptor.decrypt(data);
@ -503,6 +503,17 @@ define([
}; };
if (data.password) { folderData.password = data.password; } if (data.password) { folderData.password = data.password; }
if (data.owned) { folderData.owners = [Env.edPublic]; } 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) { }).nThen(function (waitFor) {
Env.pinPads([folderData.channel], waitFor()); Env.pinPads([folderData.channel], waitFor());
}).nThen(function (waitFor) { }).nThen(function (waitFor) {

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

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

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

Loading…
Cancel
Save