From 740a715acdfffb765c21c2d83b2607155dd4d881 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 21 Oct 2018 16:05:31 +0200 Subject: [PATCH] Handle empty code when starting --- telethon/client/auth.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telethon/client/auth.py b/telethon/client/auth.py index 9fcb1bce..3222a0c8 100644 --- a/telethon/client/auth.py +++ b/telethon/client/auth.py @@ -153,6 +153,12 @@ class AuthMethods(MessageParseMethods, UserMethods): if inspect.isawaitable(value): value = await value + # Since sign-in with no code works (it sends the code) + # we must double-check that here. Else we'll assume we + # logged in, and it will return None as the User. + if not value: + raise errors.PhoneCodeEmptyError(request=None) + if sign_up: me = await self.sign_up(value, first_name, last_name) else: