Fix Destroy and change password when pad not stored

pull/1/head
yflory 4 years ago
parent c168393c21
commit c6b8b11dc3

@ -1095,6 +1095,7 @@ define([
common.changePadPassword = function (Crypt, Crypto, data, cb) { common.changePadPassword = function (Crypt, Crypto, data, cb) {
var href = data.href; var href = data.href;
var oldPassword = data.oldPassword;
var newPassword = data.password; var newPassword = data.password;
var teamId = data.teamId; var teamId = data.teamId;
if (!href) { return void cb({ error: 'EINVAL_HREF' }); } if (!href) { return void cb({ error: 'EINVAL_HREF' }); }
@ -1123,7 +1124,9 @@ define([
var isSharedFolder = parsed.type === 'drive'; var isSharedFolder = parsed.type === 'drive';
var optsGet = {}; var optsGet = {
password: oldPassword
};
var optsPut = { var optsPut = {
password: newPassword, password: newPassword,
metadata: {}, metadata: {},
@ -1133,7 +1136,7 @@ define([
var cryptgetVal; var cryptgetVal;
Nthen(function (waitFor) { Nthen(function (waitFor) {
if (parsed.hashData && parsed.hashData.password) { if (parsed.hashData && parsed.hashData.password && !oldPassword) {
common.getPadAttribute('password', waitFor(function (err, password) { common.getPadAttribute('password', waitFor(function (err, password) {
optsGet.password = password; optsGet.password = password;
}), href); }), href);
@ -1418,6 +1421,7 @@ define([
common.changeOOPassword = function (data, _cb) { common.changeOOPassword = function (data, _cb) {
var cb = Util.once(Util.mkAsync(_cb)); var cb = Util.once(Util.mkAsync(_cb));
var href = data.href; var href = data.href;
var oldPassword = data.oldPassword;
var newPassword = data.password; var newPassword = data.password;
var teamId = data.teamId; var teamId = data.teamId;
if (!href) { return void cb({ error: 'EINVAL_HREF' }); } if (!href) { return void cb({ error: 'EINVAL_HREF' }); }
@ -1452,12 +1456,16 @@ define([
validateKey: newSecret.keys.validateKey validateKey: newSecret.keys.validateKey
}, },
}; };
var optsGet = {}; var optsGet = {
password: oldPassword
};
Nthen(function (waitFor) { Nthen(function (waitFor) {
common.getPadAttribute('', waitFor(function (err, _data) { common.getPadAttribute('', waitFor(function (err, _data) {
padData = _data; padData = _data;
optsGet.password = padData.password; if (!oldPassword) {
optsGet.password = padData.password;
}
}), href); }), href);
common.getAccessKeys(waitFor(function (keys) { common.getAccessKeys(waitFor(function (keys) {
optsGet.accessKeys = keys; optsGet.accessKeys = keys;

@ -888,9 +888,16 @@ define([
}); });
} }
var href = data.href;
var hashes = priv.hashes || {};
var bestHash = hashes.editHash || hashes.viewHash || hashes.fileHash;
if (data.fakeHref) {
href = Hash.hashToHref(bestHash, priv.app);
}
sframeChan.query(q, { sframeChan.query(q, {
teamId: typeof(owned) !== "boolean" ? owned : undefined, teamId: typeof(owned) !== "boolean" ? owned : undefined,
href: data.href, href: href,
oldPassword: priv.password,
password: newPass password: newPass
}, function (err, data) { }, function (err, data) {
$(passwordOk).text(Messages.properties_changePasswordButton); $(passwordOk).text(Messages.properties_changePasswordButton);
@ -956,7 +963,7 @@ define([
spinner.spin(); spinner.spin();
sframeChan.query('Q_DELETE_OWNED', { sframeChan.query('Q_DELETE_OWNED', {
teamId: typeof(owned) !== "boolean" ? owned : undefined, teamId: typeof(owned) !== "boolean" ? owned : undefined,
channel: data.channel channel: data.channel || priv.channel
}, function (err, obj) { }, function (err, obj) {
spinner.done(); spinner.done();
UI.findCancelButton().click(); UI.findCancelButton().click();

@ -331,6 +331,8 @@ define([
teamId = data.teamId; teamId = data.teamId;
} }
// XXX CLEAR CACHE
if (channel === store.driveChannel && !force) { if (channel === store.driveChannel && !force) {
return void cb({error: 'User drive removal blocked!'}); return void cb({error: 'User drive removal blocked!'});
} }

@ -868,7 +868,6 @@ define([
if (fId && Env.folders[fId] && Env.folders[fId].deleting) { if (fId && Env.folders[fId] && Env.folders[fId].deleting) {
delete Env.folders[fId].deleting; delete Env.folders[fId].deleting;
} }
console.error(obj.error, chan);
Feedback.send('ERROR_DELETING_OWNED_PAD=' + chan + '|' + obj.error, true); Feedback.send('ERROR_DELETING_OWNED_PAD=' + chan + '|' + obj.error, true);
return void cb(); return void cb();
} }
@ -881,6 +880,11 @@ define([
ids.push(fId); ids.push(fId);
} }
if (!ids.length) {
toDelete = undefined;
return void cb();
}
ids.forEach(function (id) { ids.forEach(function (id) {
var paths = findFile(Env, id); var paths = findFile(Env, id);
var _resolved = _resolvePaths(Env, paths); var _resolved = _resolvePaths(Env, paths);
@ -912,8 +916,13 @@ define([
}); });
}); });
}).nThen(function () { }).nThen(function () {
// Remove deleted pads from the drive if (!toDelete) {
_delete(Env, { resolved: toDelete }, cb); // Nothing to delete
cb();
} else {
// Remove deleted pads from the drive
_delete(Env, { resolved: toDelete }, cb);
}
// If we were using the access modal, send a refresh command // If we were using the access modal, send a refresh command
if (data.channel) { if (data.channel) {
Env.Store.refreshDriveUI(); Env.Store.refreshDriveUI();

@ -1407,6 +1407,7 @@ define([
}; };
config.data = { config.data = {
app: parsed.type, app: parsed.type,
channel: secret.channel,
hashes: hashes, hashes: hashes,
password: password, password: password,
isTemplate: isTemplate, isTemplate: isTemplate,

@ -101,6 +101,7 @@ define([
origin: window.location.origin, origin: window.location.origin,
pathname: window.location.pathname, pathname: window.location.pathname,
feedbackAllowed: Utils.Feedback.state, feedbackAllowed: Utils.Feedback.state,
channel: config.data.channel,
hashes: config.data.hashes, hashes: config.data.hashes,
password: config.data.password, password: config.data.password,
propChannels: config.data.getPropChannels(), propChannels: config.data.getPropChannels(),

Loading…
Cancel
Save