mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-23 11:43:20 +00:00
Fixed mesh in user group rights.
This commit is contained in:
@@ -61,6 +61,11 @@ namespace MeshCentralRouter
|
|||||||
ulong rights = node.rights; // Direct device rights
|
ulong rights = node.rights; // Direct device rights
|
||||||
if (mesh != null) { rights |= mesh.rights; } // Device group 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 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
|
// Must have remote control rights
|
||||||
if ((rights & 8) != 0)
|
if ((rights & 8) != 0)
|
||||||
|
|||||||
@@ -280,6 +280,17 @@ namespace MeshCentralRouter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dictionary<string, ulong> newlinks = new Dictionary<string, ulong>();
|
||||||
|
foreach (string j in links.Keys)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> urights = ((Dictionary<string, object>)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
|
// Update the mesh
|
||||||
if (meshes.ContainsKey(meshid))
|
if (meshes.ContainsKey(meshid))
|
||||||
{
|
{
|
||||||
@@ -287,6 +298,7 @@ namespace MeshCentralRouter
|
|||||||
mesh.name = meshname;
|
mesh.name = meshname;
|
||||||
mesh.desc = meshdesc;
|
mesh.desc = meshdesc;
|
||||||
mesh.rights = meshrights;
|
mesh.rights = meshrights;
|
||||||
|
mesh.links = newlinks;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -295,6 +307,7 @@ namespace MeshCentralRouter
|
|||||||
mesh.desc = meshdesc;
|
mesh.desc = meshdesc;
|
||||||
mesh.rights = meshrights;
|
mesh.rights = meshrights;
|
||||||
mesh.type = meshtype;
|
mesh.type = meshtype;
|
||||||
|
mesh.links = newlinks;
|
||||||
meshes[meshid] = mesh;
|
meshes[meshid] = mesh;
|
||||||
}
|
}
|
||||||
wc.WriteStringWebSocket("{\"action\":\"nodes\"}");
|
wc.WriteStringWebSocket("{\"action\":\"nodes\"}");
|
||||||
@@ -395,6 +408,7 @@ namespace MeshCentralRouter
|
|||||||
m.name = (string)mesh["name"];
|
m.name = (string)mesh["name"];
|
||||||
if (mesh.ContainsKey("desc")) { m.desc = (string)mesh["desc"]; }
|
if (mesh.ContainsKey("desc")) { m.desc = (string)mesh["desc"]; }
|
||||||
m.rights = 0;
|
m.rights = 0;
|
||||||
|
m.links = new Dictionary<string, ulong>();
|
||||||
|
|
||||||
Dictionary<string, object> links = ((Dictionary<string, object>)mesh["links"]);
|
Dictionary<string, object> links = ((Dictionary<string, object>)mesh["links"]);
|
||||||
if (links.ContainsKey(userid))
|
if (links.ContainsKey(userid))
|
||||||
@@ -406,6 +420,17 @@ namespace MeshCentralRouter
|
|||||||
if (urights["rights"].GetType() == typeof(Int64)) { m.rights = (ulong)((Int64)urights["rights"]); }
|
if (urights["rights"].GetType() == typeof(Int64)) { m.rights = (ulong)((Int64)urights["rights"]); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (string j in links.Keys)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> urights = ((Dictionary<string, object>)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(string)) { m.type = int.Parse((string)mesh["mtype"]); }
|
||||||
if (mesh["mtype"].GetType() == typeof(int)) { m.type = (int)mesh["mtype"]; }
|
if (mesh["mtype"].GetType() == typeof(int)) { m.type = (int)mesh["mtype"]; }
|
||||||
meshes[m.meshid] = m;
|
meshes[m.meshid] = m;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace MeshCentralRouter
|
|||||||
public string desc;
|
public string desc;
|
||||||
public int type;
|
public int type;
|
||||||
public ulong rights;
|
public ulong rights;
|
||||||
|
public Dictionary<string, ulong> links;
|
||||||
|
|
||||||
public override string ToString() { return name; }
|
public override string ToString() { return name; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user