Handle deleted invitation error
This commit is contained in:
parent
2dd5f5fc2f
commit
d9ae669015
@ -1,5 +1,5 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
var factory = function (Hash, Util, Crypt, Nacl, Scrypt/*, Cred, nThen */) {
|
||||||
var Invite = {};
|
var Invite = {};
|
||||||
|
|
||||||
Invite.deriveSeeds = function (safeSeed) {
|
Invite.deriveSeeds = function (safeSeed) {
|
||||||
@ -44,16 +44,16 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|||||||
'base64'); // format, could be 'base64'
|
'base64'); // format, could be 'base64'
|
||||||
};
|
};
|
||||||
|
|
||||||
Invite.getPreviewContent = function (seeds, cryptgetOpts, cb) {
|
Invite.getPreviewContent = function (seeds, cryptgetOpts, _cb) {
|
||||||
setTimeout(function () {
|
var cb = Util.once(Util.mkAsync(_cb));
|
||||||
cb(void 0, {
|
// XXX test data
|
||||||
author: {
|
cb(void 0, {
|
||||||
displayName: 'Bob',
|
author: {
|
||||||
curvePublic: 'pewpewpew'
|
displayName: 'Bob',
|
||||||
},
|
curvePublic: 'pewpewpew'
|
||||||
team: 'CryptPad',
|
},
|
||||||
message: 'Hello bob'
|
team: 'CryptPad',
|
||||||
});
|
message: 'Hello bob'
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
var secrets = Invite.derivePreviewSecrets(seeds);
|
var secrets = Invite.derivePreviewSecrets(seeds);
|
||||||
@ -62,6 +62,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|||||||
var hash = Invite.derivePreviewHash(seeds);
|
var hash = Invite.derivePreviewHash(seeds);
|
||||||
Crypt.get(hash, function (err, val) {
|
Crypt.get(hash, function (err, val) {
|
||||||
if (err) { return void cb(err); }
|
if (err) { return void cb(err); }
|
||||||
|
if (!val) { return void cb('DELETED'); }
|
||||||
try {
|
try {
|
||||||
cb(void 0, JSON.parse(val));
|
cb(void 0, JSON.parse(val));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -86,6 +87,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|||||||
if (typeof(module) !== 'undefined' && module.exports) {
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
module.exports = factory(
|
module.exports = factory(
|
||||||
require("../common-hash"),
|
require("../common-hash"),
|
||||||
|
require("../common-util"),
|
||||||
require("../cryptget"), // XXX npm cryptget?
|
require("../cryptget"), // XXX npm cryptget?
|
||||||
require("tweetnacl/nacl-fast"),
|
require("tweetnacl/nacl-fast"),
|
||||||
require("scrypt-async")
|
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)) {
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
define([
|
define([
|
||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
|
'/common/common-util.js',
|
||||||
'/common/cryptget.js',
|
'/common/cryptget.js',
|
||||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||||
'/bower_components/scrypt-async/scrypt-async.min.js',
|
'/bower_components/scrypt-async/scrypt-async.min.js',
|
||||||
], function (Hash, Crypt /*, Nacl, Scrypt */) {
|
], function (Hash, Util, Crypt /*, Nacl, Scrypt */) {
|
||||||
return factory(Hash, Crypt, window.nacl, window.scrypt);
|
return factory(Hash, Util, Crypt, window.nacl, window.scrypt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|||||||
@ -1054,8 +1054,10 @@ define([
|
|||||||
h('i.fa.fa-spin.fa-spinner')
|
h('i.fa.fa-spin.fa-spinner')
|
||||||
]);
|
]);
|
||||||
var $div = $(div);
|
var $div = $(div);
|
||||||
|
var errorBlock;
|
||||||
cb([
|
cb([
|
||||||
h('h2', 'Team invitation'), // XXX
|
h('h2', 'Team invitation'), // XXX
|
||||||
|
errorBlock = h('div.alert.alert-danger', {style: 'display: none;'}),
|
||||||
div
|
div
|
||||||
]);
|
]);
|
||||||
var inviteDiv = h('div');
|
var inviteDiv = h('div');
|
||||||
@ -1100,6 +1102,11 @@ define([
|
|||||||
origin: privateData.origin
|
origin: privateData.origin
|
||||||
}, waitFor(function (err, json) {
|
}, waitFor(function (err, json) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
// err === DELETED: different message?
|
||||||
|
$(errorBlock).text('ERROR'+err).show(); // XXX
|
||||||
|
waitFor.abort();
|
||||||
|
$div.empty();
|
||||||
|
return;
|
||||||
// XXX handle errors
|
// XXX handle errors
|
||||||
}
|
}
|
||||||
json = json; // XXX {message: "", author: "", ???}
|
json = json; // XXX {message: "", author: "", ???}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user