Fix sign_up call to sign_in

This commit is contained in:
Lonami Exo 2022-02-17 11:30:18 +01:00
parent 94ac667e79
commit 80d44cb75b

View File

@ -248,10 +248,9 @@ async def sign_up(
*, *,
code: typing.Union[str, int]) -> '_tl.User': code: typing.Union[str, int]) -> '_tl.User':
if not self._phone_code_hash: if not self._phone_code_hash:
# This check is also present in sign_in but we do it here to customize the error message
raise ValueError('Must call client.send_code_request before sign up') raise ValueError('Must call client.send_code_request before sign up')
phone, phone_code_hash = self._phone_code_hash
# To prevent abuse, one has to try to sign in before signing up. This # To prevent abuse, one has to try to sign in before signing up. This
# is the current way in which Telegram validates the code to sign up. # is the current way in which Telegram validates the code to sign up.
# #
@ -261,11 +260,7 @@ async def sign_up(
# We're emulating pre-layer 104 behaviour so except the right error: # We're emulating pre-layer 104 behaviour so except the right error:
if not self._tos: if not self._tos:
try: try:
return await self.sign_in( return await self.sign_in(code=code)
phone=phone,
code=code,
phone_code_hash=phone_code_hash,
)
except errors.SignUpRequired: except errors.SignUpRequired:
pass # code is correct and was used, now need to sign in pass # code is correct and was used, now need to sign in