auth: better error when user terminates session
Signed-off-by: Sumner Evans <sumner@beeper.com>
This commit is contained in:
@@ -35,6 +35,7 @@ from telethon.errors import (
|
|||||||
PhoneNumberInvalidError,
|
PhoneNumberInvalidError,
|
||||||
PhoneNumberUnoccupiedError,
|
PhoneNumberUnoccupiedError,
|
||||||
SessionPasswordNeededError,
|
SessionPasswordNeededError,
|
||||||
|
SessionRevokedError,
|
||||||
)
|
)
|
||||||
|
|
||||||
from mautrix.bridge import InvalidAccessToken, OnlyLoginSelf
|
from mautrix.bridge import InvalidAccessToken, OnlyLoginSelf
|
||||||
@@ -342,6 +343,14 @@ class AuthAPI(abc.ABC):
|
|||||||
errcode="password_invalid",
|
errcode="password_invalid",
|
||||||
error="Incorrect password.",
|
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:
|
except Exception as e:
|
||||||
self.log.exception("Error sending password")
|
self.log.exception("Error sending password")
|
||||||
if isinstance(e, ValueError) and "You must provide a phone and a code" in str(e):
|
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",
|
state="password",
|
||||||
status=500,
|
status=500,
|
||||||
errcode="unknown_error",
|
errcode="unknown_error",
|
||||||
error="Internal server error while sending password.",
|
error=f"Internal server error while sending password. {e}",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user