diff --git a/src/python/backend.py b/src/python/backend.py index 16dc48da..1cbefb43 100644 --- a/src/python/backend.py +++ b/src/python/backend.py @@ -51,12 +51,15 @@ class Backend: device_id: Optional[str] = None, homeserver: str = "https://matrix.org", ) -> Tuple[bool, str]: + client = MatrixClient( self, user=user, homeserver=homeserver, device_id=device_id, ) + try: await client.login(password) except RuntimeError as err: + await client.close() return (False, err.args[0].message) self.clients[client.user_id] = client