Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ It is available only after `CONNACK (rc=0)`, otherwise it is `null` in cases:
- after `CONNACK (rc!=0)` response
- `connectionError` raised by aedes

## client.username

- `<string>` __Default__: `null`

Client username, specified by CONNECT packet.

It is available only after a successful call to `aedes.authenticate()`, where it
will be set to the username specifed by the client, or `null` if no username was supplied.

## client.clean

- `<boolean>` __Default__: `true`
Expand Down
7 changes: 6 additions & 1 deletion lib/handlers/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ function init (client, packet, done) {
function authenticate (arg, done) {
const client = this.client
client.pause()
let username = this.username;
client.broker.authenticate(
client,
this.packet.username,
username,
this.packet.password,
negate)

Expand All @@ -113,6 +114,10 @@ function authenticate (arg, done) {
}
if (!err && successful) {
client._authorized = true
if (typeof(client.username) == "undefined") {
// check it's undefined, it could have been set in preConnect
client.username = username || null;
}
return done()
}

Expand Down