git » sdk » commit b06a46f

Strophe doesn't signal auth failure, so imply it

author Stephen Paul Weber
2024-07-24 01:31:02 UTC
committer Stephen Paul Weber
2024-07-24 01:31:02 UTC
parent 49b5c558c3abf58bbea44e7414f279534319ed4f

Strophe doesn't signal auth failure, so imply it

snikket/Client.hx +1 -1
snikket/streams/XmppStropheStream.hx +8 -1

diff --git a/snikket/Client.hx b/snikket/Client.hx
index dcba8e9..4519de3 100644
--- a/snikket/Client.hx
+++ b/snikket/Client.hx
@@ -481,7 +481,7 @@ class Client extends EventEmitter {
 
 						stream.on("auth/password-needed", (data) -> {
 							fastMechanism = data.mechanisms?.find((mech) -> mech.canFast)?.name;
-							if (token == null || fastMechanism == null) {
+							if (token == null || (fastMechanism == null && data.mechanimsms != null)) {
 								this.trigger("auth/password-needed", { accountId: accountId() });
 							} else {
 								this.stream.trigger("auth/password", { password: token, mechanism: fastMechanism, fastCount: fastCount });
diff --git a/snikket/streams/XmppStropheStream.hx b/snikket/streams/XmppStropheStream.hx
index 6b7741d..e6aa44f 100644
--- a/snikket/streams/XmppStropheStream.hx
+++ b/snikket/streams/XmppStropheStream.hx
@@ -232,9 +232,16 @@ class XmppStropheStream extends GenericStream {
 			stream.trigger("status/online", {});
 		}
 		if (event == untyped __cpp__("XMPP_CONN_DISCONNECT")) {
-			stream.trigger("status/offline", {});
+			if (!stream.ready) {
+				// Never connected, auth failure
+				stream.trigger("auth/fail", {});
+			} else {
+				stream.ready = false;
+				stream.trigger("status/offline", {});
+			}
 		}
 		if (event == untyped __cpp__("XMPP_CONN_FAIL")) {
+			stream.ready = false;
 			stream.trigger("status/offline", {});
 		}
 	}