Handle deleted invitation error

pull/1/head
yflory 5 years ago
parent 2dd5f5fc2f
commit d9ae669015

@ -1,5 +1,5 @@
(function () {
var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
var factory = function (Hash, Util, Crypt, Nacl, Scrypt/*, Cred, nThen */) {
var Invite = {};
Invite.deriveSeeds = function (safeSeed) {
@ -44,8 +44,9 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
'base64'); // format, could be 'base64'
};
Invite.getPreviewContent = function (seeds, cryptgetOpts, cb) {
setTimeout(function () {
Invite.getPreviewContent = function (seeds, cryptgetOpts, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
// XXX test data
cb(void 0, {
author: {
displayName: 'Bob',
@ -54,7 +55,6 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
team: 'CryptPad',
message: 'Hello bob'
});
});
/*
var secrets = Invite.derivePreviewSecrets(seeds);
secrets = secrets;
@ -62,6 +62,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
var hash = Invite.derivePreviewHash(seeds);
Crypt.get(hash, function (err, val) {
if (err) { return void cb(err); }
if (!val) { return void cb('DELETED'); }
try {
cb(void 0, JSON.parse(val));
} catch (e) {
@ -86,6 +87,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
if (typeof(module) !== 'undefined' && module.exports) {
module.exports = factory(
require("../common-hash"),
require("../common-util"),
require("../cryptget"), // XXX npm cryptget?
require("tweetnacl/nacl-fast"),
require("scrypt-async")
@ -93,11 +95,12 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
define([
'/common/common-hash.js',
'/common/common-util.js',
'/common/cryptget.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
'/bower_components/scrypt-async/scrypt-async.min.js',
], function (Hash, Crypt /*, Nacl, Scrypt */) {
return factory(Hash, Crypt, window.nacl, window.scrypt);
], function (Hash, Util, Crypt /*, Nacl, Scrypt */) {
return factory(Hash, Util, Crypt, window.nacl, window.scrypt);
});
}
}());

@ -1054,8 +1054,10 @@ define([
h('i.fa.fa-spin.fa-spinner')
]);
var $div = $(div);
var errorBlock;
cb([
h('h2', 'Team invitation'), // XXX
errorBlock = h('div.alert.alert-danger', {style: 'display: none;'}),
div
]);
var inviteDiv = h('div');
@ -1100,6 +1102,11 @@ define([
origin: privateData.origin
}, waitFor(function (err, json) {
if (err) {
// err === DELETED: different message?
$(errorBlock).text('ERROR'+err).show(); // XXX
waitFor.abort();
$div.empty();
return;
// XXX handle errors
}
json = json; // XXX {message: "", author: "", ???}

Loading…
Cancel
Save