Skip to content

Commit

Permalink
[Community] make community auth error more clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Oct 26, 2024
1 parent 86a34c3 commit 9991c9d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions octobot/community/supabase_backend/community_supabase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 9991c9d

Please sign in to comment.