diff --git a/DeviceUserControl.cs b/DeviceUserControl.cs index c9b7b82..15dfb12 100644 --- a/DeviceUserControl.cs +++ b/DeviceUserControl.cs @@ -61,6 +61,11 @@ namespace MeshCentralRouter ulong rights = node.rights; // Direct device rights if (mesh != null) { rights |= mesh.rights; } // Device group rights foreach (string i in node.links.Keys) { if (parent.meshcentral.userGroups.ContainsKey(i)) { rights |= node.links[i]; } } // Take a look at group rights + foreach (string i in parent.meshcentral.userRights.Keys) { + if ((i.StartsWith("ugrp/")) && (mesh.links.ContainsKey(i))) { + rights |= (ulong)mesh.links[i]; + } + } // Must have remote control rights if ((rights & 8) != 0) diff --git a/MeshCentralServer.cs b/MeshCentralServer.cs index 92f3fba..1760b02 100644 --- a/MeshCentralServer.cs +++ b/MeshCentralServer.cs @@ -280,6 +280,17 @@ namespace MeshCentralRouter } } + Dictionary newlinks = new Dictionary(); + foreach (string j in links.Keys) + { + Dictionary urights = ((Dictionary)links[j]); + if (urights != null) + { + if (urights["rights"].GetType() == typeof(int)) { newlinks[j] = (ulong)((int)urights["rights"]); } + if (urights["rights"].GetType() == typeof(Int64)) { newlinks[j] = (ulong)((Int64)urights["rights"]); } + } + } + // Update the mesh if (meshes.ContainsKey(meshid)) { @@ -287,6 +298,7 @@ namespace MeshCentralRouter mesh.name = meshname; mesh.desc = meshdesc; mesh.rights = meshrights; + mesh.links = newlinks; } else { @@ -295,6 +307,7 @@ namespace MeshCentralRouter mesh.desc = meshdesc; mesh.rights = meshrights; mesh.type = meshtype; + mesh.links = newlinks; meshes[meshid] = mesh; } wc.WriteStringWebSocket("{\"action\":\"nodes\"}"); @@ -395,6 +408,7 @@ namespace MeshCentralRouter m.name = (string)mesh["name"]; if (mesh.ContainsKey("desc")) { m.desc = (string)mesh["desc"]; } m.rights = 0; + m.links = new Dictionary(); Dictionary links = ((Dictionary)mesh["links"]); if (links.ContainsKey(userid)) @@ -406,6 +420,17 @@ namespace MeshCentralRouter if (urights["rights"].GetType() == typeof(Int64)) { m.rights = (ulong)((Int64)urights["rights"]); } } } + + foreach (string j in links.Keys) + { + Dictionary urights = ((Dictionary)links[j]); + if (urights != null) + { + if (urights["rights"].GetType() == typeof(int)) { m.links[j] = (ulong)((int)urights["rights"]); } + if (urights["rights"].GetType() == typeof(Int64)) { m.links[j] = (ulong)((Int64)urights["rights"]); } + } + } + if (mesh["mtype"].GetType() == typeof(string)) { m.type = int.Parse((string)mesh["mtype"]); } if (mesh["mtype"].GetType() == typeof(int)) { m.type = (int)mesh["mtype"]; } meshes[m.meshid] = m; diff --git a/NodeClass.cs b/NodeClass.cs index 0f57fd1..dd0d497 100644 --- a/NodeClass.cs +++ b/NodeClass.cs @@ -29,6 +29,7 @@ namespace MeshCentralRouter public string desc; public int type; public ulong rights; + public Dictionary links; public override string ToString() { return name; } }