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());
};
config.onError = function (info) {
finish(Session, info.error);
};
config.onChannelError = function (info) {
finish(Session, info.error);
};

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

@ -1730,7 +1730,9 @@ define([
&& $target.parents('#cp-app-drive-content')) {
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;
};
var onFileDrop = APP.onFileDrop = function (file, e) {

@ -1600,7 +1600,16 @@ define([
// server
Cryptpad.useTemplate({
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();
cb();
}, cryptputCfg);
@ -1608,7 +1617,16 @@ define([
}
// if we open a new code from a file
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();
cb();
}, cryptputCfg);

Loading…
Cancel
Save