1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Fixed event dispatching bug.

This commit is contained in:
Ylian Saint-Hilaire 2021-11-10 17:56:12 -08:00
parent 6dceb842d7
commit aab50dcbef
5 changed files with 52 additions and 23 deletions

View file

@ -941,21 +941,21 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
return obj;
}
function checkDeviceSharePublicIdentifier(parent, domain, nodeid, pid, func) {
function checkDeviceSharePublicIdentifier(parent, domain, nodeid, pid, extraKey, func) {
// Check the public id
parent.db.GetAllTypeNodeFiltered([nodeid], domain.id, 'deviceshare', null, function (err, docs) {
if ((err != null) || (docs.length == 0)) { func(false); return; }
// Search for the device share public identifier
var found = false;
for (var i = 0; i < docs.length; i++) { if (docs[i].publicid == pid) { found = true; } }
for (var i = 0; i < docs.length; i++) { if ((docs[i].publicid == pid) && ((docs[i].extrakey == null) || (docs[i].extrakey === extraKey))) { found = true; } }
func(found);
});
}
module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie) {
if ((cookie != null) && (typeof cookie.nid == 'string') && (typeof cookie.pid == 'string')) {
checkDeviceSharePublicIdentifier(parent, domain, cookie.nid, cookie.pid, function (result) {
checkDeviceSharePublicIdentifier(parent, domain, cookie.nid, cookie.pid, cookie.k, function (result) {
// If the identifier if not found, close the connection
if (result == false) { try { ws.close(); } catch (e) { } return; }
// Public device sharing identifier found, continue as normal.