From 7ea0e29afd83a5b3fea7261ce113823688828419 Mon Sep 17 00:00:00 2001 From: mrlt8 <67088095+mrlt8@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:46:27 -0700 Subject: [PATCH] Fix restore user data on restart #1334 --- app/wyze_bridge.py | 3 ++- app/wyzebridge/auth.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/wyze_bridge.py b/app/wyze_bridge.py index ff83a202..2ec7b23a 100644 --- a/app/wyze_bridge.py +++ b/app/wyze_bridge.py @@ -34,7 +34,8 @@ def run(self, fresh_data: bool = False) -> None: def _initialize(self, fresh_data: bool = False) -> None: self.api.login(fresh_data=fresh_data) - WbAuth.set_email(email=self.api.creds.email, force=fresh_data) + email = self.api.creds.email or self.api.get_user().email + WbAuth.set_email(email=email, force=fresh_data) self.mtx.setup_auth(WbAuth.api, STREAM_AUTH) self.setup_streams() if self.streams.total < 1: diff --git a/app/wyzebridge/auth.py b/app/wyzebridge/auth.py index b4de82f2..3bc27bfe 100644 --- a/app/wyzebridge/auth.py +++ b/app/wyzebridge/auth.py @@ -68,7 +68,7 @@ def set_email(cls, email: str, force: bool = False): cls._update_credentials(email, force) logger.info(f"[AUTH] WB_USERNAME={cls.username}") - logger.info(f"[AUTH] WB_PASSWORD={cls._pass[0]}{'*'*(len(cls._pass)-1)}") + logger.info(f"[AUTH] WB_PASSWORD={redact_password(cls._pass)}") logger.info(f"[AUTH] WB_API={cls.api}") @classmethod @@ -83,4 +83,8 @@ def _update_credentials(cls, email: str, force: bool = False) -> None: cls.api = get_credential("wb_api") or gen_api_key(email) +def redact_password(password: Optional[str]): + return f"{password[0]}{'*' * (len(password) - 1)}" if password else "NOT SET" + + STREAM_AUTH: str = env_bool("STREAM_AUTH", style="original")