Fix account deletion issue

pull/1/head
yflory 5 years ago
parent 043b2d24ea
commit 8d9301e427

@ -727,10 +727,13 @@ define([
// Owned drive
if (metadata && metadata.owners && metadata.owners.length === 1 &&
metadata.owners.indexOf(edPublic) !== -1) {
var token;
nThen(function (waitFor) {
self.accountDeletion = clientId;
// Log out from other workers
var token = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
store.proxy[Constants.tokenKey] = token;
postMessage(clientId, "DELETE_ACCOUNT", token, waitFor());
onSync(null, waitFor());
}).nThen(function (waitFor) {
removeOwnedPads(waitFor);
}).nThen(function (waitFor) {
@ -745,6 +748,10 @@ define([
force: true
}, waitFor());
}).nThen(function () {
// XXX users need to login after registration if they register after account deletion (token issue?)
// XXX delete block
// Log out current worker
postMessage(clientId, "DELETE_ACCOUNT", token, function () {});
store.network.disconnect();
cb({
state: true
@ -2663,6 +2670,7 @@ define([
};
Store.disconnect = function () {
if (self.accountDeletion) { return; }
if (!store.network) { return; }
store.network.disconnect();
};

@ -63,8 +63,11 @@ var init = function (client, cb) {
}
if (q === "DISCONNECT") {
console.log('Deleting existing store!');
delete self.Rpc;
delete self.store;
client.close();
if (self.accountDeletion && self.accountDeletion === client.id) {
delete self.Rpc;
delete self.store;
}
}
});
});

Loading…
Cancel
Save