Fix 'change user password' overriding existing data

pull/1/head
yflory 5 years ago
parent f98ffee07a
commit da0bb6f95b

@ -1604,6 +1604,26 @@ define([
var allocated = Login.allocateBytes(bytes);
blockKeys = allocated.blockKeys;
}));
}).nThen(function (waitFor) {
var blockUrl = Block.getBlockUrl(blockKeys);
// Check whether there is a block at that location
Util.fetch(blockUrl, waitFor(function (err, block) {
// If there is no block or the block is invalid, continue.
if (err) {
console.log("no block found");
return;
}
var decryptedBlock = Block.decrypt(block, blockKeys);
if (!decryptedBlock) {
console.error("Found a login block but failed to decrypt");
return;
}
// If there is already a valid block, abort! We risk overriding another user's data
waitFor.abort();
cb({ error: 'EEXISTS' });
}));
}).nThen(function (waitFor) {
// Write the new login block
var temp = {

@ -488,6 +488,7 @@ define([
UI.removeLoadingScreen();
if (obj && obj.error) {
// TODO
// XXX EEXISTS error message?
UI.alert(Messages.settings_changePasswordError);
}
});

Loading…
Cancel
Save