Fix joining your own team

pull/1/head
yflory 5 years ago
parent 361292ff01
commit 826a86c7d6

@ -1489,6 +1489,17 @@ define([
inviteContent = obj;
}));
}).nThen(function (waitFor) {
// Check if you're already a member of this team
var chan = Util.find(inviteContent, ['teamData', 'channel']);
var myTeams = ctx.store.proxy.teams || {};
var isMember = Object.keys(myTeams).some(function (k) {
var t = myTeams[k];
return t.channel === chan;
});
if (isMember) {
waitFor.abort();
return void cb({error: 'ALREADY_MEMBER'});
}
// Accept the roster invitation: relplace our ephemeral keys with our user keys
var rosterData = Util.find(inviteContent, ['teamData', 'keys', 'roster']);
var myKeys = inviteContent.ephemeral;
@ -1512,12 +1523,12 @@ define([
var state = roster.getState();
rosterState = state.members[myKeys.curvePublic];
roster.accept(myData.curvePublic, waitFor(function (err) {
roster.stop();
if (err) {
waitFor.abort();
console.error(err);
return void cb({error: 'ACCEPT_ERROR'});
}
roster.stop();
}));
}));
}).nThen(function () {

@ -1127,6 +1127,7 @@ define([
password: pw,
}, waitFor(function (obj) {
if (obj && obj.error) {
console.error(obj.error);
// Wrong password or other error...
waitFor.abort();
if (obj.error === 'INVALID_INVITE_CONTENT') {

Loading…
Cancel
Save