]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Normalize the credentials presence check
authorlhchavez <lhchavez@lhchavez.com>
Thu, 11 Mar 2021 13:38:13 +0000 (05:38 -0800)
committerlhchavez <lhchavez@lhchavez.com>
Thu, 11 Mar 2021 14:42:11 +0000 (06:42 -0800)
Most places that check for the presence / absence of credentials compare
them against `undefined`, except the one for Plain authentication.

This change makes the very last place to use the same pattern (instead
of checking for falsiness) for consistency. Additionally, there are ways
to configure PAM to accept empty passwords, so it's possible for a user
to legitimately send an empty string as password.

core/rfb.js

index e3786cba58855627002ebc692e2d64f267c5d8dd..05a5979431fdbcbbaa7a26646e32c227467d52a1 100644 (file)
@@ -1427,8 +1427,8 @@ export default class RFB extends EventTargetMixin {
 
         // negotiated Plain subtype, server waits for password
         if (this._rfbVeNCryptState == 4) {
-            if (!this._rfbCredentials.username ||
-                !this._rfbCredentials.password) {
+            if (this._rfbCredentials.username === undefined ||
+                this._rfbCredentials.password === undefined) {
                 this.dispatchEvent(new CustomEvent(
                     "credentialsrequired",
                     { detail: { types: ["username", "password"] } }));