Fixed agent invite codes to make them unique per domain.

This commit is contained in:
Ylian Saint-Hilaire 2020-04-30 18:52:45 -07:00
parent ab2dd569c5
commit 3b11d528c3
3 changed files with 3 additions and 3 deletions

View File

@ -2457,7 +2457,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var dup = null; var dup = null;
for (var i in command.invite.codes) { for (var i in command.invite.codes) {
for (var j in parent.meshes) { 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) { if (dup != null) {

View File

@ -29886,4 +29886,4 @@
] ]
} }
] ]
} }

View File

@ -1481,7 +1481,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Each for a device group that has this invite code. // Each for a device group that has this invite code.
for (var i in obj.meshes) { 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. // 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) : '')); 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; return;