Potential fix

This commit is contained in:
Zach Fox 2017-01-19 10:20:36 -08:00
parent 0ec01c0dc5
commit 534fcd9399
3 changed files with 20 additions and 16 deletions

View file

@ -793,30 +793,32 @@ void DomainServerSettingsManager::processUsernameFromIDRequestPacket(QSharedPoin
// Setup the packet // Setup the packet
auto usernameFromIDReplyPacket = NLPacket::create(PacketType::UsernameFromIDReply); 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) // 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 // OR if the message is from a node whose UUID matches the one in the packet
if (sendingNode->getCanKick() || nodeUUID == sendingNode->getUUID()) { if (sendingNode->getCanKick() || nodeUUID == sendingNode->getUUID()) {
// It's time to figure out the username // It's time to figure out the username
QString verifiedUsername = matchingNode->getPermissions().getVerifiedUserName(); verifiedUsername = matchingNode->getPermissions().getVerifiedUserName();
usernameFromIDReplyPacket->write(nodeUUID.toRfc4122());
usernameFromIDReplyPacket->writeString(verifiedUsername); usernameFromIDReplyPacket->writeString(verifiedUsername);
// now put in the machine fingerprint // now put in the machine fingerprint
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(matchingNode->getLinkedData()); DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
QUuid machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid(); machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid();
usernameFromIDReplyPacket->write(machineFingerprint.toRfc4122()); usernameFromIDReplyPacket->write(machineFingerprint.toRfc4122());
qDebug() << "Sending username" << verifiedUsername << "and machine fingerprint" << machineFingerprint << "associated with node" << nodeUUID << ". Node admin status: " << isAdmin;
} else { } else {
usernameFromIDReplyPacket->write(nodeUUID.toRfc4122()); usernameFromIDReplyPacket->writeString(verifiedUsername);
usernameFromIDReplyPacket->writeString(""); usernameFromIDReplyPacket->writeString(machineFingerprint.toRfc4122());
usernameFromIDReplyPacket->writeString("");
} }
// Write whether or not the user is an admin // Write whether or not the user is an admin
bool isAdmin = matchingNode->getCanKick();
usernameFromIDReplyPacket->writePrimitive(isAdmin); usernameFromIDReplyPacket->writePrimitive(isAdmin);
qDebug() << "Sending username" << verifiedUsername << "and machine fingerprint" << machineFingerprint << "associated with node" << nodeUUID << ". Node admin status: " << isAdmin;
// Ship it! // Ship it!
limitedNodeList->sendPacket(std::move(usernameFromIDReplyPacket), *sendingNode); limitedNodeList->sendPacket(std::move(usernameFromIDReplyPacket), *sendingNode);
} else { } else {

View file

@ -135,7 +135,7 @@ signals:
/**jsdoc /**jsdoc
* Notifies scripts of the username and machine fingerprint associated with a UUID. * 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 * @function Users.usernameFromIDReply
*/ */
void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint, bool isAdmin); void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint, bool isAdmin);

View file

@ -271,7 +271,7 @@ function populateUserList() {
admin: false admin: false
}; };
// Request the username, fingerprint, and admin status from the given UUID // 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); Users.requestUsernameFromID(id);
// Request personal mute status and ignore status // Request personal mute status and ignore status
// from NodeList (as long as we're not requesting it for our own ID) // 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 the ID we've received is our ID...
if (MyAvatar.sessionUUID === id) { if (MyAvatar.sessionUUID === id) {
// Set the data to contain specific strings. // Set the data to contain specific strings.
data = ['', username]; data = ['', username, isAdmin];
} else { } else if (Users.canKick) {
// Set the data to contain the ID and the username (if we have one) // Set the data to contain the ID and the username (if we have one)
// or fingerprint (if we don't have a username) string. // 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)); print('Username Data:', JSON.stringify(data));
// Ship the data off to QML // Ship the data off to QML
pal.sendToQml({ method: 'updateUsername', params: data }); pal.sendToQml({ method: 'updateUsername', params: data });