Add error message when trying to copy a restricted pad

pull/1/head
yflory 4 years ago
parent 84e32d73a3
commit b0eebf1071

@ -76,6 +76,9 @@ define([
finish(Session, void 0, rt.getUserDoc()); finish(Session, void 0, rt.getUserDoc());
}; };
config.onError = function (info) {
finish(Session, info.error);
};
config.onChannelError = function (info) { config.onChannelError = function (info) {
finish(Session, info.error); finish(Session, info.error);
}; };

@ -632,7 +632,12 @@ define([
} }
}).nThen(function () { }).nThen(function () {
Crypt.get(parsed.hash, function (err, val) { Crypt.get(parsed.hash, function (err, val) {
if (err) { throw new Error(err); } if (err) {
return void cb(err);
}
if (!val) {
return void cb('ENOENT');
}
try { try {
// Try to fix the title before importing the template // Try to fix the title before importing the template
var parsed = JSON.parse(val); var parsed = JSON.parse(val);
@ -665,14 +670,14 @@ define([
Crypt.get(parsed.hash, _waitFor(function (err, _val) { Crypt.get(parsed.hash, _waitFor(function (err, _val) {
if (err) { if (err) {
_waitFor.abort(); _waitFor.abort();
return void cb(); return void cb(err);
} }
try { try {
val = JSON.parse(_val); val = JSON.parse(_val);
fixPadMetadata(val, true); fixPadMetadata(val, true);
} catch (e) { } catch (e) {
_waitFor.abort(); _waitFor.abort();
return void cb(); return void cb(e.message);
} }
}), optsGet); }), optsGet);
return; return;
@ -691,7 +696,7 @@ define([
Util.fetch(src, waitFor(function (err, _u8) { Util.fetch(src, waitFor(function (err, _u8) {
if (err) { if (err) {
_waitFor.abort(); _waitFor.abort();
return void waitFor.abort(); return void cb(err);
} }
u8 = _u8; u8 = _u8;
})); }));
@ -700,7 +705,7 @@ define([
FileCrypto.decrypt(u8, key, waitFor(function (err, _res) { FileCrypto.decrypt(u8, key, waitFor(function (err, _res) {
if (err || !_res.content) { if (err || !_res.content) {
_waitFor.abort(); _waitFor.abort();
return void waitFor.abort(); return void cb(err);
} }
res = _res; res = _res;
})); }));

@ -1730,7 +1730,9 @@ define([
&& $target.parents('#cp-app-drive-content')) { && $target.parents('#cp-app-drive-content')) {
newPath = currentPath; newPath = currentPath;
} }
if (newPath[0] !== ROOT) { newPath = [ROOT]; } // XXX Why did we add the following line?
// https://github.com/xwiki-labs/cryptpad/commit/f103a0fb08d137901174ef7e15dbc2c9a2ec3ca1
//if (newPath[0] !== ROOT) { newPath = [ROOT]; }
return newPath; return newPath;
}; };
var onFileDrop = APP.onFileDrop = function (file, e) { var onFileDrop = APP.onFileDrop = function (file, e) {

@ -1600,7 +1600,16 @@ define([
// server // server
Cryptpad.useTemplate({ Cryptpad.useTemplate({
href: data.template href: data.template
}, Cryptget, function () { }, Cryptget, function (err) {
if (err) {
// TODO: better messages in case of expired, deleted, etc.?
if (err === 'ERESTRICTED') {
sframeChan.event('EV_RESTRICTED_ERROR');
} else {
sframeChan.query("EV_LOADING_ERROR", "DELETED");
}
return;
}
startRealtime(); startRealtime();
cb(); cb();
}, cryptputCfg); }, cryptputCfg);
@ -1608,7 +1617,16 @@ define([
} }
// if we open a new code from a file // if we open a new code from a file
if (Cryptpad.fromFileData) { if (Cryptpad.fromFileData) {
Cryptpad.useFile(Cryptget, function () { Cryptpad.useFile(Cryptget, function (err) {
if (err) {
// TODO: better messages in case of expired, deleted, etc.?
if (err === 'ERESTRICTED') {
sframeChan.event('EV_RESTRICTED_ERROR');
} else {
sframeChan.query("EV_LOADING_ERROR", "DELETED");
}
return;
}
startRealtime(); startRealtime();
cb(); cb();
}, cryptputCfg); }, cryptputCfg);

Loading…
Cancel
Save