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
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<DomainServerNodeData*>(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 {

View file

@ -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);

View file

@ -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 });