Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(conn): password can be set when username unset when mqttv5 #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion writeToStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ function connect (packet, stream, opts) {

// Password
if (password != null) {
if (!providedUsername) {
if (!providedUsername && protocolVersion !== 5) {
robertsLando marked this conversation as resolved.
Show resolved Hide resolved
// `username` is not required when password is present in MQTT-v5
// see also: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901044
Comment on lines +204 to +205
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this comment above the if for consistency

stream.destroy(new Error('Username is required to use password'))
return false
}
Expand Down