From 35ee01cb285bc0c711aaedbdb057de86979cbc58 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 1 Nov 2022 16:44:05 +0100 Subject: [PATCH] reset fast token on login failure --- src/main/java/eu/siacs/conversations/entities/Account.java | 5 +++++ .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 4457e4d1f..7c5f22b27 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -362,6 +362,11 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable this.fastToken = token; } + public void resetFastToken() { + this.fastMechanism = null; + this.fastToken = null; + } + public void resetPinnedMechanism() { this.pinnedMechanism = null; this.pinnedChannelBinding = null; diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index fc753ec34..1793c9f29 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -840,7 +840,11 @@ public class XmppConnection implements Runnable { } Log.d(Config.LOGTAG,failure.toString()); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": login failure " + version); - //TODO check if we are doing FAST; reset token + if (this.saslMechanism instanceof HashedToken) { + Log.d(Config.LOGTAG,account.getJid().asBareJid() + ": resetting token"); + account.resetFastToken(); + mXmppConnectionService.databaseBackend.updateAccount(account); + } if (failure.hasChild("temporary-auth-failure")) { throw new StateChangingException(Account.State.TEMPORARY_AUTH_FAILURE); } else if (failure.hasChild("account-disabled")) {