1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-27 13:48:49 +08:00

Fix MQTT client id bug (#319)

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
This commit is contained in:
Aleksandar Novaković 2018-05-30 13:48:40 +02:00 committed by Nikola Marčetić
parent 7590578745
commit 89e69d132a

View File

@ -71,7 +71,7 @@ aedes.authorizePublish = function (client, packet, publish) {
logger.info('authorized publish');
rawMsg = message.RawMessage.encode({
Publisher: client.id,
Publisher: client.thingId,
Channel: channel,
Protocol: 'mqtt',
Payload: packet.payload
@ -116,11 +116,12 @@ aedes.authenticate = function (client, username, password, acknowledge) {
identity = {value: pass},
onIdentify = function(err, res) {
if (!err) {
client.id = res.value.toString() || "";
client.thingId = res.value.toString() || "";
client.id = client.id || client.thingId;
client.password = pass;
acknowledge(null, true);
} else {
logger.warn('failed to authenticate client with key %s', password);
logger.warn('failed to authenticate client with key %s', pass);
acknowledge(err, false);
}
};