From b06a46f97407145746a205c8b6e63642ad462ce2 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 23 Jul 2024 20:31:02 -0500 Subject: [PATCH] Strophe doesn't signal auth failure, so imply it --- snikket/Client.hx | 2 +- snikket/streams/XmppStropheStream.hx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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", {}); } }