Skip to content

Commit

Permalink
fix name display for oauth (#5980)
Browse files Browse the repository at this point in the history
Signed-off-by: si458 <simonsmith5521@gmail.com>
  • Loading branch information
si458 committed Apr 1, 2024
1 parent d2a0946 commit 9294488
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions meshuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
5 changes: 5 additions & 0 deletions views/default.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit 9294488

Please sign in to comment.