fix name display for oauth (#5980)

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-04-01 15:48:01 +01:00 committed by GitHub
parent d2a0946f22
commit 9294488d4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -815,6 +815,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if ((xipkvmport != null) && (xipkvmport.sessions != null)) { docs[i].sessions = xipkvmport.sessions; }
}
// Patch node links with names, like meshes links with names
for (var a in docs[i].links) {
if (!docs[i].links[a].name) {
if (parent.users[a].realname) { docs[i].links[a].name = parent.users[a].realname; }
else if (parent.users[a].name) { docs[i].links[a].name = parent.users[a].name; }
}
}
r[meshid].push(docs[i]);
}
const response = { action: 'nodes', responseid: command.responseid, nodes: r, tag: command.tag };

View File

@ -7879,6 +7879,8 @@
useridlist.sort();
for (var i in useridlist) {
var trash = '', rights = '', userid = useridlist[i], srights = currentNode.links[userid].rights, username = EscapeHtml(userid.split('/')[2]), rights = makeUserDeviceRightsString(srights), ugroup = false;
if (currentNode.links[userid].name != null) { username = EscapeHtml(currentNode.links[userid].name); }
if (userid == userinfo._id) { username = EscapeHtml(userinfo.name); }
if ((users != null) && (users[userid] != null)) { username = EscapeHtml(users[userid].name); }
if ((usergroups != null) && (usergroups[userid] != null)) { username = EscapeHtml(usergroups[userid].name); ugroup = true; }
if ((meshrights & 2) != 0) {
@ -18963,6 +18965,9 @@
var useridsplit = userid.split('/'), userid2 = useridsplit[0] + '/' + useridsplit[1] + '/' + useridsplit[2], guestname = '';
if ((useridsplit.length == 4) && (useridsplit[3].startsWith('guest:'))) { guestname = ' - ' + decode_utf8(atob(useridsplit[3].substring(6))); }
if (users && users[userid2] != null) { if (users[userid2].realname != null) return (users[userid2].realname + guestname); else return (users[userid2].name + guestname); }
if (currentNode && currentNode.links && currentNode.links[userid] && currentNode.links[userid].name != null) { return (currentNode.links[userid].name + guestname); }
if (userid == userinfo._id) { return (userinfo.name + guestname); }
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); } } } }
return (useridsplit[2] + guestname);
}
function round(value, precision) { var multiplier = Math.pow(10, precision || 0); return Math.round(value * multiplier) / multiplier; }