fix name display for oauth (#5980)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Apr 1, 2024 at 15:48 UTC
9294488d4ed9032c2a16cd24f82cefc3ef70c21c
2 files changed
+13
meshuser.js
+8
@@ -815,6 +815,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
815
if ((xipkvmport != null) && (xipkvmport.sessions != null)) { docs[i].sessions = xipkvmport.sessions; }
816
}
817
818
+ // Patch node links with names, like meshes links with names
819
+ for (var a in docs[i].links) {
820
+ if (!docs[i].links[a].name) {
821
+ if (parent.users[a].realname) { docs[i].links[a].name = parent.users[a].realname; }
822
+ else if (parent.users[a].name) { docs[i].links[a].name = parent.users[a].name; }
823
+ }
824
+ }
825
+
826
r[meshid].push(docs[i]);
827
}
828
const response = { action: 'nodes', responseid: command.responseid, nodes: r, tag: command.tag };
views/default.handlebars
+5
@@ -7879,6 +7879,8 @@
7879
useridlist.sort();
7880
for (var i in useridlist) {
7881
var trash = '', rights = '', userid = useridlist[i], srights = currentNode.links[userid].rights, username = EscapeHtml(userid.split('/')[2]), rights = makeUserDeviceRightsString(srights), ugroup = false;
7882
+ if (currentNode.links[userid].name != null) { username = EscapeHtml(currentNode.links[userid].name); }
7883
+ if (userid == userinfo._id) { username = EscapeHtml(userinfo.name); }
7884
if ((users != null) && (users[userid] != null)) { username = EscapeHtml(users[userid].name); }
7885
if ((usergroups != null) && (usergroups[userid] != null)) { username = EscapeHtml(usergroups[userid].name); ugroup = true; }
7886
if ((meshrights & 2) != 0) {
@@ -18963,6 +18965,9 @@
18965
var useridsplit = userid.split('/'), userid2 = useridsplit[0] + '/' + useridsplit[1] + '/' + useridsplit[2], guestname = '';
18966
if ((useridsplit.length == 4) && (useridsplit[3].startsWith('guest:'))) { guestname = ' - ' + decode_utf8(atob(useridsplit[3].substring(6))); }
18967
if (users && users[userid2] != null) { if (users[userid2].realname != null) return (users[userid2].realname + guestname); else return (users[userid2].name + guestname); }
18968
+ if (currentNode && currentNode.links && currentNode.links[userid] && currentNode.links[userid].name != null) { return (currentNode.links[userid].name + guestname); }
18969
+ if (userid == userinfo._id) { return (userinfo.name + guestname); }
18970
+ if (nodes) { for (var a in nodes) { if (nodes[a].links) { for (var b in nodes[a].links) { if (nodes[a].links[b].name && b == userid) return (nodes[a].links[b].name + guestname); } } } }
18971
return (useridsplit[2] + guestname);
18972
}
18973
function round(value, precision) { var multiplier = Math.pow(10, precision || 0); return Math.round(value * multiplier) / multiplier; }