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); cb(obj);
}); });
}; };
common.loadSharedFolder = function (id, data, cb) {
postMessage("LOAD_SHARED_FOLDER", {
id: id,
data: data
}, cb);
};
// Settings and ready // Settings and ready
common.mergeAnonDrive = function (cb) { common.mergeAnonDrive = function (cb) {
var data = { var data = {

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

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

@ -39,7 +39,7 @@ define([
var getSecrets = function (Cryptpad, Utils, cb) { var getSecrets = function (Cryptpad, Utils, cb) {
var hash = window.location.hash.slice(1); var hash = window.location.hash.slice(1);
var secret = Utils.Hash.getSecrets('drive', hash); var secret = Utils.Hash.getSecrets('drive', hash);
if (hash) { if (hash && Utils.LocalStore.isLoggedIn()) {
// Add a shared folder! // Add a shared folder!
// TODO password? // TODO password?
Cryptpad.addSharedFolder(secret, function (id) { Cryptpad.addSharedFolder(secret, function (id) {
@ -53,6 +53,16 @@ define([
cb(null, secret); cb(null, secret);
}); });
return; 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 // No password for drive
cb(null, secret); cb(null, secret);

Loading…
Cancel
Save