From 9991c9da411186ec411306bfe531f795a199f09d Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Sat, 26 Oct 2024 10:37:44 +0200 Subject: [PATCH] [Community] make community auth error more clearer --- .../supabase_backend/community_supabase_client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/octobot/community/supabase_backend/community_supabase_client.py b/octobot/community/supabase_backend/community_supabase_client.py index 636980a99..370d7ca02 100644 --- a/octobot/community/supabase_backend/community_supabase_client.py +++ b/octobot/community/supabase_backend/community_supabase_client.py @@ -99,7 +99,7 @@ async def sign_in(self, email: str, password: str) -> None: if "email" in str(err).lower(): # AuthApiError('Email not confirmed') raise errors.EmailValidationRequiredError(err) from err - raise authentication.FailedAuthentication(err) from err + raise authentication.FailedAuthentication(f"Community auth error: {err}") from err async def sign_up(self, email: str, password: str) -> None: try: @@ -117,7 +117,7 @@ async def sign_up(self, email: str, password: str) -> None: if self._requires_email_validation(resp.user): raise errors.EmailValidationRequiredError() except gotrue.errors.AuthError as err: - raise authentication.AuthenticationError(err) from err + raise authentication.AuthenticationError(f"Community auth error: {err}") from err async def sign_out(self, options: gotrue.types.SignOutOptions) -> None: try: @@ -132,13 +132,13 @@ async def restore_session(self): self.event_loop = asyncio.get_event_loop() await self.auth.initialize_from_storage() if not self.is_signed_in(): - raise authentication.FailedAuthentication() + raise authentication.FailedAuthentication(f"Community auth error: restoring session failed") async def refresh_session(self, refresh_token: typing.Union[str, None] = None): try: await self.auth.refresh_session(refresh_token=refresh_token) except gotrue.errors.AuthError as err: - raise authentication.AuthenticationError(err) from err + raise authentication.AuthenticationError(f"Community auth error: {err}") from err async def sign_in_with_otp_token(self, token): self.event_loop = asyncio.get_event_loop() @@ -156,7 +156,7 @@ async def sign_in_with_otp_token(self, token): except gotrue.errors.AuthImplicitGrantRedirectError as err: if saved_session: await self.auth._storage.set_item(self.auth._storage_key, saved_session) - raise authentication.AuthenticationError(err) from err + raise authentication.AuthenticationError(f"Community auth error: {err}") from err def is_signed_in(self) -> bool: # is signed in when a user auth key is set @@ -201,7 +201,7 @@ async def get_otp_with_auth_key(self, user_email: str, auth_key: str) -> str: ) return json.loads(resp)["token"] except Exception: - raise authentication.AuthenticationError(f"Invalid auth key authentication details") + raise authentication.AuthenticationError(f"Community auth error: invalid auth key authentication details") async def fetch_extensions(self, mqtt_uuid: typing.Optional[str]) -> dict: resp = await self.functions.invoke(