Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit ebf2ae1

Browse files
committed
сделал установку пароля без почты
1 parent d1a8b20 commit ebf2ae1

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/pymax/interfaces.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ async def _send_interactive_ping(self) -> None:
235235
break
236236
except Exception as e:
237237
self.logger.debug("Interactive ping failed: %s", e)
238-
# If socket is no longer connected, exit the loop
239238
if not self.is_connected:
240239
break
241240
await asyncio.sleep(DEFAULT_PING_INTERVAL)

src/pymax/mixins/auth.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ async def _set_email(self, email: str, track_id: str) -> bool:
560560
async def set_password(
561561
self,
562562
password: str,
563-
email: str | None = None,
563+
email: str | None | _Unset = UNSET,
564564
hint: str | None | _Unset = UNSET,
565565
):
566566
"""
@@ -595,6 +595,9 @@ async def set_password(
595595
self.logger.critical("Failed to create password track: track ID missing")
596596
raise ValueError("Failed to create password track")
597597

598+
has_hint = False
599+
has_email = False
600+
598601
while True:
599602
if not password:
600603
password = await asyncio.to_thread(lambda: input("Введите пароль: ").strip())
@@ -623,30 +626,40 @@ async def set_password(
623626
success = await self._set_hint(hint, track_id)
624627
if success:
625628
self.logger.info("Password hint set successfully")
629+
has_hint = True
626630
break
627631
else:
628632
self.logger.error("Failed to set password hint, please try again")
629633

630634
while True:
631-
if not email:
635+
if hint is UNSET:
632636
email = await asyncio.to_thread(
633-
lambda: input("Введите email для восстановления пароля: ").strip()
637+
lambda: input(
638+
"Введите email для восстановления пароля (пустой - пропустить): "
639+
).strip()
634640
)
635641
if not email:
636-
self.logger.warning("Email is empty, please try again")
637-
continue
642+
break
643+
644+
if email is None:
645+
break
638646

639647
success = await self._set_email(email, track_id)
640648
if success:
649+
has_email = True
641650
self.logger.info("Recovery email set successfully")
642651
break
643652

653+
expected_capabilities = [Capability.DEFAULT]
654+
655+
if has_hint:
656+
expected_capabilities.append(Capability.SECOND_FACTOR_HAS_HINT)
657+
658+
if has_email:
659+
expected_capabilities.append(Capability.SECOND_FACTOR_HAS_EMAIL)
660+
644661
payload = SetTwoFactorPayload(
645-
expected_capabilities=[
646-
Capability.DEFAULT,
647-
Capability.SECOND_FACTOR_HAS_HINT,
648-
Capability.SECOND_FACTOR_HAS_EMAIL,
649-
],
662+
expected_capabilities=expected_capabilities,
650663
track_id=track_id,
651664
password=password,
652665
hint=hint if isinstance(hint, (str, type(None))) else None,

0 commit comments

Comments
 (0)