Add safety measures to avoid removing your drive by accident
This commit is contained in:
parent
d823deff92
commit
5c6b3155ac
@ -254,8 +254,12 @@ define([
|
|||||||
common.clearOwnedChannel = function (channel, cb) {
|
common.clearOwnedChannel = function (channel, cb) {
|
||||||
postMessage("CLEAR_OWNED_CHANNEL", channel, cb);
|
postMessage("CLEAR_OWNED_CHANNEL", channel, cb);
|
||||||
};
|
};
|
||||||
common.removeOwnedChannel = function (channel, cb) {
|
// "force" allows you to delete your drive ID
|
||||||
postMessage("REMOVE_OWNED_CHANNEL", channel, cb);
|
common.removeOwnedChannel = function (channel, cb, force) {
|
||||||
|
postMessage("REMOVE_OWNED_CHANNEL", {
|
||||||
|
channel: channel,
|
||||||
|
force: force
|
||||||
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
common.getDeletedPads = function (data, cb) {
|
common.getDeletedPads = function (data, cb) {
|
||||||
@ -769,7 +773,7 @@ define([
|
|||||||
waitFor.abort();
|
waitFor.abort();
|
||||||
return void cb(obj);
|
return void cb(obj);
|
||||||
}
|
}
|
||||||
}));
|
}), true);
|
||||||
common.unpinPads([oldChannel], waitFor());
|
common.unpinPads([oldChannel], waitFor());
|
||||||
common.pinPads([newSecret.channel], waitFor());
|
common.pinPads([newSecret.channel], waitFor());
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
@ -950,7 +954,7 @@ define([
|
|||||||
common.logoutFromAll(waitFor(function () {
|
common.logoutFromAll(waitFor(function () {
|
||||||
postMessage("DISCONNECT");
|
postMessage("DISCONNECT");
|
||||||
}));
|
}));
|
||||||
}));
|
}), true);
|
||||||
}
|
}
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
if (!oldIsOwned) {
|
if (!oldIsOwned) {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ define([
|
|||||||
var sendDriveEvent = function () {};
|
var sendDriveEvent = function () {};
|
||||||
var registerProxyEvents = function () {};
|
var registerProxyEvents = function () {};
|
||||||
|
|
||||||
var storeHash;
|
var storeHash, storeChannel;
|
||||||
|
|
||||||
var store = window.CryptPad_AsyncStore = {
|
var store = window.CryptPad_AsyncStore = {
|
||||||
modules: {}
|
modules: {}
|
||||||
@ -239,6 +239,20 @@ define([
|
|||||||
|
|
||||||
Store.removeOwnedChannel = function (clientId, data, cb) {
|
Store.removeOwnedChannel = function (clientId, data, cb) {
|
||||||
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
||||||
|
|
||||||
|
// "data" used to be a string (channelID), now it can also be an object
|
||||||
|
// data.force tells us we can safely remove the drive ID
|
||||||
|
var channel = data;
|
||||||
|
var force = false;
|
||||||
|
if (typeof(data) === "object") {
|
||||||
|
channel = data.channel;
|
||||||
|
force = data.force;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel === storeChannel && !force) {
|
||||||
|
return void cb({error: 'User drive removal blocked!'});
|
||||||
|
}
|
||||||
|
|
||||||
store.rpc.removeOwnedChannel(data, function (err) {
|
store.rpc.removeOwnedChannel(data, function (err) {
|
||||||
cb({error:err});
|
cb({error:err});
|
||||||
});
|
});
|
||||||
@ -786,6 +800,7 @@ define([
|
|||||||
var h = p.hashData;
|
var h = p.hashData;
|
||||||
|
|
||||||
if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
|
if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
|
||||||
|
if (p.type === "debug") { return void cb(); }
|
||||||
|
|
||||||
var channelData = Store.channels && Store.channels[channel];
|
var channelData = Store.channels && Store.channels[channel];
|
||||||
|
|
||||||
@ -1915,6 +1930,7 @@ define([
|
|||||||
}
|
}
|
||||||
// No password for drive
|
// No password for drive
|
||||||
var secret = Hash.getSecrets('drive', hash);
|
var secret = Hash.getSecrets('drive', hash);
|
||||||
|
storeChannel = secret.channel;
|
||||||
var listmapConfig = {
|
var listmapConfig = {
|
||||||
data: {},
|
data: {},
|
||||||
websocketURL: NetConfig.getWebsocketURL(),
|
websocketURL: NetConfig.getWebsocketURL(),
|
||||||
|
|||||||
@ -838,13 +838,6 @@ define([
|
|||||||
Cryptpad.setLanguage(data, cb);
|
Cryptpad.setLanguage(data, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_CLEAR_OWNED_CHANNEL', function (channel, cb) {
|
|
||||||
Cryptpad.clearOwnedChannel(channel, cb);
|
|
||||||
});
|
|
||||||
sframeChan.on('Q_REMOVE_OWNED_CHANNEL', function (channel, cb) {
|
|
||||||
Cryptpad.removeOwnedChannel(channel, cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
sframeChan.on('Q_GET_ALL_TAGS', function (data, cb) {
|
sframeChan.on('Q_GET_ALL_TAGS', function (data, cb) {
|
||||||
Cryptpad.listAllTags(function (err, tags) {
|
Cryptpad.listAllTags(function (err, tags) {
|
||||||
cb({
|
cb({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user