Fix resending code with empty phone hash (fix #1283)

This commit is contained in:
Lonami Exo 2019-09-27 10:33:42 +02:00
parent 6da8d1a0ec
commit 7de01a5f94

View File

@ -481,7 +481,13 @@ class AuthMethods:
except errors.AuthRestartError:
return await self.send_code_request(phone, force_sms=force_sms)
self._phone_code_hash[phone] = phone_hash = result.phone_code_hash
# If we already sent a SMS, do not resend the code (hash may be empty)
if isinstance(result.type, types.auth.SentCodeTypeSms):
force_sms = False
# phone_code_hash may be empty, if it is, do not save it (#1283)
if result.phone_code_hash:
self._phone_code_hash[phone] = phone_hash = result.phone_code_hash
else:
force_sms = True