mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-05 22:23:15 +03:00
Fix auth_key not actually being saved
This would make the user have to login every time.
This commit is contained in:
parent
7dece209a0
commit
4562ba9ccf
|
@ -312,16 +312,11 @@ class TelegramBaseClient(abc.ABC):
|
||||||
self.session.server_address, self.session.port,
|
self.session.server_address, self.session.port,
|
||||||
loop=self._loop, proxy=self._proxy
|
loop=self._loop, proxy=self._proxy
|
||||||
))
|
))
|
||||||
|
self.session.auth_key = self._sender.auth_key
|
||||||
|
|
||||||
await self._sender.send(self._init_with(
|
await self._sender.send(self._init_with(
|
||||||
functions.help.GetConfigRequest()))
|
functions.help.GetConfigRequest()))
|
||||||
|
|
||||||
# AuthKey is a property, so re-setting it has side-effects.
|
|
||||||
# Since it's used as a reference and only its inner payload
|
|
||||||
# may have actually changed after connecting, we use the
|
|
||||||
# reference from the session file itself as its value.
|
|
||||||
self.session.auth_key = self.session.auth_key
|
|
||||||
|
|
||||||
self._updates_handle = self._loop.create_task(self._update_loop())
|
self._updates_handle = self._loop.create_task(self._update_loop())
|
||||||
|
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
|
|
|
@ -68,8 +68,8 @@ class MTProtoSender:
|
||||||
self._recv_loop_handle = None
|
self._recv_loop_handle = None
|
||||||
|
|
||||||
# Preserving the references of the AuthKey and state is important
|
# Preserving the references of the AuthKey and state is important
|
||||||
self._auth_key = auth_key or AuthKey(None)
|
self.auth_key = auth_key or AuthKey(None)
|
||||||
self._state = MTProtoState(self._auth_key)
|
self._state = MTProtoState(self.auth_key)
|
||||||
|
|
||||||
# Outgoing messages are put in a queue and sent in a batch.
|
# Outgoing messages are put in a queue and sent in a batch.
|
||||||
# Note that here we're also storing their ``_RequestState``.
|
# Note that here we're also storing their ``_RequestState``.
|
||||||
|
@ -204,12 +204,12 @@ class MTProtoSender:
|
||||||
.format(self._retries))
|
.format(self._retries))
|
||||||
|
|
||||||
__log__.debug('Connection success!')
|
__log__.debug('Connection success!')
|
||||||
if not self._auth_key:
|
if not self.auth_key:
|
||||||
plain = MTProtoPlainSender(self._connection)
|
plain = MTProtoPlainSender(self._connection)
|
||||||
for retry in range(1, self._retries + 1):
|
for retry in range(1, self._retries + 1):
|
||||||
try:
|
try:
|
||||||
__log__.debug('New auth_key attempt {}...'.format(retry))
|
__log__.debug('New auth_key attempt {}...'.format(retry))
|
||||||
self._auth_key.key, self._state.time_offset =\
|
self.auth_key.key, self._state.time_offset =\
|
||||||
await authenticator.do_authentication(plain)
|
await authenticator.do_authentication(plain)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -402,7 +402,7 @@ class MTProtoSender:
|
||||||
else:
|
else:
|
||||||
__log__.warning('Invalid buffer %s', e)
|
__log__.warning('Invalid buffer %s', e)
|
||||||
|
|
||||||
self._auth_key.key = None
|
self.auth_key.key = None
|
||||||
self._start_reconnect()
|
self._start_reconnect()
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user