Load shared folder when not logged in

pull/1/head
yflory 6 years ago
parent 0e04c4392c
commit 17bc1ee703

@ -89,6 +89,12 @@ define([
cb(obj);
});
};
common.loadSharedFolder = function (id, data, cb) {
postMessage("LOAD_SHARED_FOLDER", {
id: id,
data: data
}, cb);
};
// Settings and ready
common.mergeAnonDrive = function (cb) {
var data = {

@ -1239,6 +1239,9 @@ define([
}
return rt;
};
Store.loadSharedFolderAnon = function (clientId, data, cb) {
loadSharedFolder(data.id, data.data, cb);
};
Store.addSharedFolder = function (clientId, data, cb) {
Store.userObjectCommand(clientId, {
cmd: 'addSharedFolder',

@ -56,6 +56,7 @@ define([
INCREMENT_TEMPLATE_USE: Store.incrementTemplateUse,
GET_SHARED_FOLDER: Store.getSharedFolder,
ADD_SHARED_FOLDER: Store.addSharedFolder,
LOAD_SHARED_FOLDER: Store.loadSharedFolderAnon,
// Messaging
INVITE_FROM_USERLIST: Store.inviteFromUserlist,
ADD_DIRECT_MESSAGE_HANDLERS: Store.addDirectMessageHandlers,

@ -39,7 +39,7 @@ define([
var getSecrets = function (Cryptpad, Utils, cb) {
var hash = window.location.hash.slice(1);
var secret = Utils.Hash.getSecrets('drive', hash);
if (hash) {
if (hash && Utils.LocalStore.isLoggedIn()) {
// Add a shared folder!
// TODO password?
Cryptpad.addSharedFolder(secret, function (id) {
@ -53,6 +53,16 @@ define([
cb(null, secret);
});
return;
} else if (hash) {
var id = Utils.Util.createRandomInteger();
window.CryptPad_newSharedFolder = id;
var data = {
href: Utils.Hash.getRelativeHref(window.location.href),
};
Cryptpad.loadSharedFolder(id, data, function () {
cb(null, secret);
});
return;
}
// No password for drive
cb(null, secret);

Loading…
Cancel
Save