From 11576ca5f31298f4408f56bb36ab3656f21f3491 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 30 Apr 2020 18:52:45 -0700 Subject: [PATCH] Fixed agent invite codes to make them unique per domain. --- meshuser.js | 2 +- translate/translate.json | 2 +- webserver.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/meshuser.js b/meshuser.js index 059cfdc1..ebd84d82 100644 --- a/meshuser.js +++ b/meshuser.js @@ -2457,7 +2457,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use var dup = null; for (var i in command.invite.codes) { for (var j in parent.meshes) { - if ((j != command.meshid) && (parent.meshes[j].invite != null) && (parent.meshes[j].invite.codes.indexOf(command.invite.codes[i]) >= 0)) { dup = command.invite.codes[i]; break; } + if ((j != command.meshid) && (parent.meshes[j].domain == domain.id) && (parent.meshes[j].invite != null) && (parent.meshes[j].invite.codes.indexOf(command.invite.codes[i]) >= 0)) { dup = command.invite.codes[i]; break; } } } if (dup != null) { diff --git a/translate/translate.json b/translate/translate.json index b1e05d50..6f846a01 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -29886,4 +29886,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/webserver.js b/webserver.js index 7bd88b11..fd2686d5 100644 --- a/webserver.js +++ b/webserver.js @@ -1481,7 +1481,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { // Each for a device group that has this invite code. for (var i in obj.meshes) { - if ((obj.meshes[i].invite != null) && (obj.meshes[i].invite.codes.indexOf(req.body.inviteCode) >= 0)) { + if ((obj.meshes[i].domain == domain.id) && (obj.meshes[i].invite != null) && (obj.meshes[i].invite.codes.indexOf(req.body.inviteCode) >= 0)) { // Send invitation link, valid for 1 minute. res.redirect(domain.url + 'agentinvite?c=' + parent.encodeCookie({ a: 4, mid: i, f: obj.meshes[i].invite.flags, expire: 1 }, parent.invitationLinkEncryptionKey) + (req.query.key ? ('&key=' + req.query.key) : '')); return;