diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index 8731167428..f7859ac1e0 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -793,30 +793,32 @@ void DomainServerSettingsManager::processUsernameFromIDRequestPacket(QSharedPoin // Setup the packet auto usernameFromIDReplyPacket = NLPacket::create(PacketType::UsernameFromIDReply); - bool isAdmin = matchingNode->getCanKick(); + QString verifiedUsername; + QUuid machineFingerprint; + + // Write the UUID to the packet + usernameFromIDReplyPacket->write(nodeUUID.toRfc4122()); // Check if the sending node has permission to kick (is an admin) // OR if the message is from a node whose UUID matches the one in the packet if (sendingNode->getCanKick() || nodeUUID == sendingNode->getUUID()) { // It's time to figure out the username - QString verifiedUsername = matchingNode->getPermissions().getVerifiedUserName(); - - usernameFromIDReplyPacket->write(nodeUUID.toRfc4122()); + verifiedUsername = matchingNode->getPermissions().getVerifiedUserName(); usernameFromIDReplyPacket->writeString(verifiedUsername); // now put in the machine fingerprint DomainServerNodeData* nodeData = reinterpret_cast(matchingNode->getLinkedData()); - QUuid machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid(); + machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid(); usernameFromIDReplyPacket->write(machineFingerprint.toRfc4122()); - qDebug() << "Sending username" << verifiedUsername << "and machine fingerprint" << machineFingerprint << "associated with node" << nodeUUID << ". Node admin status: " << isAdmin; } else { - usernameFromIDReplyPacket->write(nodeUUID.toRfc4122()); - usernameFromIDReplyPacket->writeString(""); - usernameFromIDReplyPacket->writeString(""); + usernameFromIDReplyPacket->writeString(verifiedUsername); + usernameFromIDReplyPacket->writeString(machineFingerprint.toRfc4122()); } // Write whether or not the user is an admin + bool isAdmin = matchingNode->getCanKick(); usernameFromIDReplyPacket->writePrimitive(isAdmin); - + + qDebug() << "Sending username" << verifiedUsername << "and machine fingerprint" << machineFingerprint << "associated with node" << nodeUUID << ". Node admin status: " << isAdmin; // Ship it! limitedNodeList->sendPacket(std::move(usernameFromIDReplyPacket), *sendingNode); } else { diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 5ae1d5a75b..76b98c6217 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -135,7 +135,7 @@ signals: /**jsdoc * Notifies scripts of the username and machine fingerprint associated with a UUID. - * Username and machineFingerprint will be empty strings if the requesting user isn't an admin. + * Username and machineFingerprint will be their default constructor output if the requesting user isn't an admin. * @function Users.usernameFromIDReply */ void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint, bool isAdmin); diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 6e8d3bc163..cbfac76545 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -271,7 +271,7 @@ function populateUserList() { admin: false }; // Request the username, fingerprint, and admin status from the given UUID - // Username and fingerprint returns "" if the requesting user isn't an admin + // Username and fingerprint returns default constructor output if the requesting user isn't an admin Users.requestUsernameFromID(id); // Request personal mute status and ignore status // from NodeList (as long as we're not requesting it for our own ID) @@ -292,13 +292,15 @@ function usernameFromIDReply(id, username, machineFingerprint, isAdmin) { // If the ID we've received is our ID... if (MyAvatar.sessionUUID === id) { // Set the data to contain specific strings. - data = ['', username]; - } else { + data = ['', username, isAdmin]; + } else if (Users.canKick) { // Set the data to contain the ID and the username (if we have one) // or fingerprint (if we don't have a username) string. - data = [id, username || machineFingerprint]; + data = [id, username || machineFingerprint, isAdmin]; + } else { + // Set the data to contain specific strings. + data = [id, '', isAdmin]; } - data.push(isAdmin); print('Username Data:', JSON.stringify(data)); // Ship the data off to QML pal.sendToQml({ method: 'updateUsername', params: data });