mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-03 11:40:11 +03:00
Enhanced flow
Enhanced flow if two-steps verification is enabled
This commit is contained in:
parent
48d6f15850
commit
11032cddd1
|
@ -317,14 +317,17 @@ class AuthMethods:
|
||||||
|
|
||||||
if phone and not code and not password:
|
if phone and not code and not password:
|
||||||
return await self.send_code_request(phone)
|
return await self.send_code_request(phone)
|
||||||
elif code:
|
elif code :
|
||||||
phone, phone_code_hash = \
|
phone, phone_code_hash = \
|
||||||
self._parse_phone_and_hash(phone, phone_code_hash)
|
self._parse_phone_and_hash(phone, phone_code_hash)
|
||||||
|
|
||||||
# May raise PhoneCodeEmptyError, PhoneCodeExpiredError,
|
# May raise PhoneCodeEmptyError, PhoneCodeExpiredError,
|
||||||
# PhoneCodeHashEmptyError or PhoneCodeInvalidError.
|
# PhoneCodeHashEmptyError or PhoneCodeInvalidError.
|
||||||
result = await self(functions.auth.SignInRequest(
|
try:
|
||||||
phone, phone_code_hash, str(code)))
|
result = await self(functions.auth.SignInRequest(
|
||||||
|
phone, phone_code_hash, str(code)))
|
||||||
|
except errors.RPCError:
|
||||||
|
return self.sign_in(password=password)
|
||||||
elif password:
|
elif password:
|
||||||
pwd = await self(functions.account.GetPasswordRequest())
|
pwd = await self(functions.account.GetPasswordRequest())
|
||||||
result = await self(functions.auth.CheckPasswordRequest(
|
result = await self(functions.auth.CheckPasswordRequest(
|
||||||
|
@ -338,7 +341,7 @@ class AuthMethods:
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'You must provide a phone and a code the first time, '
|
'You must provide a phone and a code the first time, '
|
||||||
'and a password only if an RPCError was raised before.'
|
'and a password if two-steps verification is enabled '
|
||||||
)
|
)
|
||||||
|
|
||||||
return self._on_login(result.user)
|
return self._on_login(result.user)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user