Provide the secondaryKey to userObject

This commit is contained in:
yflory
2019-10-07 14:35:11 +02:00
parent dd2f0bd417
commit cf0d0e8e4b
11 changed files with 62 additions and 46 deletions

View File

@@ -249,6 +249,7 @@ define([
if (msg.author !== content.user.curvePublic) { return void cb(true); }
var channel = content.channel;
// XXX encrypted href
var res = ctx.store.manager.findChannel(channel);
var title;

View File

@@ -27,13 +27,14 @@ define([
var parsed = Hash.parsePadUrl(data.href);
var secret = Hash.getSecrets('drive', parsed.hash, data.password);
var secondaryKey = secret.keys.secondaryKey;
var sf = allSharedFolders[secret.channel];
if (sf && sf.ready && sf.rt) {
// The shared folder is already loaded, return its data
setTimeout(function () {
var leave = function () { SF.leave(secret.channel, teamId); };
store.manager.addProxy(id, sf.rt.proxy, leave);
store.manager.addProxy(id, sf.rt.proxy, leave, secondaryKey);
cb(sf.rt, sf.metadata);
});
sf.team.push(teamId);
@@ -84,7 +85,7 @@ define([
}
sf.queue.forEach(function (obj) {
var leave = function () { SF.leave(secret.channel, teamId); };
obj.store.manager.addProxy(obj.id, rt.proxy, leave);
obj.store.manager.addProxy(obj.id, rt.proxy, leave, secondaryKey);
obj.cb(rt, info.metadata);
});
sf.leave = info.leave;

View File

@@ -215,6 +215,11 @@ define([
cb(id, rt);
});
};
var teamData = ctx.store.proxy.teams[team.id];
var secret;
if (teamData) {
secret = Hash.getSecrets('team', teamData.hash, teamData.password);
}
var manager = team.manager = ProxyManager.create(proxy.drive, {
onSync: function (cb) { ctx.Store.onSync(id, cb); },
edPublic: keys.drive.edPublic,
@@ -223,7 +228,8 @@ define([
loadSharedFolder: loadSharedFolder,
settings: {
drive: Util.find(ctx.store, ['proxy', 'settings', 'drive'])
}
},
editKey: secret && secret.keys.secondaryKey
}, {
outer: true,
removeOwnedChannel: function (channel, cb) {

View File

@@ -36,7 +36,7 @@ define([
var id = exp.getIdFromHref(href);
if (!id) { return void cb("E_INVAL_HREF"); }
if (!attr || !attr.trim()) { return void cb("E_INVAL_ATTR"); }
var data = exp.getFileData(id);
var data = exp.getFileData(id, true);
data[attr] = clone(value);
cb(null);
};