diff --git a/telethon/client/auth.py b/telethon/client/auth.py index 7c1ed6b6..5650cd97 100644 --- a/telethon/client/auth.py +++ b/telethon/client/auth.py @@ -291,7 +291,6 @@ class AuthMethods(MessageParseMethods, UserMethods): self._self_input_peer = utils.get_input_peer( result.user, allow_self=False ) - self._authorized = True return result.user async def sign_up(self, code, first_name, last_name=''): @@ -344,7 +343,6 @@ class AuthMethods(MessageParseMethods, UserMethods): self._self_input_peer = utils.get_input_peer( result.user, allow_self=False ) - self._authorized = True return result.user async def send_code_request(self, phone, *, force_sms=False): @@ -398,9 +396,10 @@ class AuthMethods(MessageParseMethods, UserMethods): except errors.RPCError: return False + self._self_input_peer = None + self._state.pts = -1 await self.disconnect() await self.session.delete() - self._authorized = False return True async def edit_2fa( diff --git a/telethon/client/telegrambaseclient.py b/telethon/client/telegrambaseclient.py index 98e14592..cecd6236 100644 --- a/telethon/client/telegrambaseclient.py +++ b/telethon/client/telegrambaseclient.py @@ -246,9 +246,6 @@ class TelegramBaseClient(abc.ABC): self._borrowed_senders = {} self._borrow_sender_lock = asyncio.Lock(loop=self._loop) - # Save whether the user is authorized here (a.k.a. logged in) - self._authorized = None # None = We don't know yet - self._updates_handle = None self._last_request = time.time() self._channel_pts = {} @@ -380,7 +377,6 @@ class TelegramBaseClient(abc.ABC): Callback from the sender whenever it needed to generate a new authorization key. This means we are not authorized. """ - self._authorized = None self.session.auth_key = auth_key await self.session.save() @@ -487,7 +483,6 @@ class TelegramBaseClient(abc.ABC): # when needed by ._get_dc, and also it's static so it's likely # set already. Avoid invoking non-CDN methods by not syncing updates. client.connect(_sync_updates=False) - client._authorized = self._authorized return client # endregion