From b291c246f4ac1b290b41a7c4a960433c97d0be12 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Wed, 12 Apr 2023 22:37:47 -0600 Subject: [PATCH] auth: better error when user terminates session Signed-off-by: Sumner Evans --- mautrix_telegram/web/common/auth_api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mautrix_telegram/web/common/auth_api.py b/mautrix_telegram/web/common/auth_api.py index 119768f2..c7a38357 100644 --- a/mautrix_telegram/web/common/auth_api.py +++ b/mautrix_telegram/web/common/auth_api.py @@ -35,6 +35,7 @@ from telethon.errors import ( PhoneNumberInvalidError, PhoneNumberUnoccupiedError, SessionPasswordNeededError, + SessionRevokedError, ) from mautrix.bridge import InvalidAccessToken, OnlyLoginSelf @@ -342,6 +343,14 @@ class AuthAPI(abc.ABC): errcode="password_invalid", error="Incorrect password.", ) + except SessionRevokedError: + return self.get_login_response( + mxid=user.mxid, + state="request", + status=401, + errcode="session_revoked", + error="Login cancelled because you terminated all of the sessions from your phone.", + ) except Exception as e: self.log.exception("Error sending password") if isinstance(e, ValueError) and "You must provide a phone and a code" in str(e): @@ -357,5 +366,5 @@ class AuthAPI(abc.ABC): state="password", status=500, errcode="unknown_error", - error="Internal server error while sending password.", + error=f"Internal server error while sending password. {e}", )