Fix is_user_authorized after log_out

This commit is contained in:
Lonami Exo 2018-10-12 19:57:16 +02:00
parent 6e77f583f1
commit e677a6bb05
2 changed files with 2 additions and 8 deletions

View File

@ -291,7 +291,6 @@ class AuthMethods(MessageParseMethods, UserMethods):
self._self_input_peer = utils.get_input_peer( self._self_input_peer = utils.get_input_peer(
result.user, allow_self=False result.user, allow_self=False
) )
self._authorized = True
return result.user return result.user
async def sign_up(self, code, first_name, last_name=''): 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( self._self_input_peer = utils.get_input_peer(
result.user, allow_self=False result.user, allow_self=False
) )
self._authorized = True
return result.user return result.user
async def send_code_request(self, phone, *, force_sms=False): async def send_code_request(self, phone, *, force_sms=False):
@ -398,9 +396,10 @@ class AuthMethods(MessageParseMethods, UserMethods):
except errors.RPCError: except errors.RPCError:
return False return False
self._self_input_peer = None
self._state.pts = -1
await self.disconnect() await self.disconnect()
await self.session.delete() await self.session.delete()
self._authorized = False
return True return True
async def edit_2fa( async def edit_2fa(

View File

@ -246,9 +246,6 @@ class TelegramBaseClient(abc.ABC):
self._borrowed_senders = {} self._borrowed_senders = {}
self._borrow_sender_lock = asyncio.Lock(loop=self._loop) 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._updates_handle = None
self._last_request = time.time() self._last_request = time.time()
self._channel_pts = {} self._channel_pts = {}
@ -380,7 +377,6 @@ class TelegramBaseClient(abc.ABC):
Callback from the sender whenever it needed to generate a Callback from the sender whenever it needed to generate a
new authorization key. This means we are not authorized. new authorization key. This means we are not authorized.
""" """
self._authorized = None
self.session.auth_key = auth_key self.session.auth_key = auth_key
await self.session.save() 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 # 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. # set already. Avoid invoking non-CDN methods by not syncing updates.
client.connect(_sync_updates=False) client.connect(_sync_updates=False)
client._authorized = self._authorized
return client return client
# endregion # endregion