Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions gotrue/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ def get_user(self, jwt: Union[str, None] = None) -> UserResponse:
`get_user()` will attempt to get the `jwt` from the current session.
"""
if not jwt:
session = self.get_session()
if session:
if session := self.get_session():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient.get_user refactored with the following changes:

jwt = session.access_token
return self._request("GET", "user", jwt=jwt, xform=parse_user_response)

Expand Down Expand Up @@ -535,15 +534,15 @@ def _enroll(self, params: MFAEnrollParams) -> AuthMFAEnrollResponse:
return response

def _challenge(self, params: MFAChallengeParams) -> AuthMFAChallengeResponse:
session = self.get_session()
if not session:
if session := self.get_session():
return self._request(
"POST",
f"factors/{params.get('factor_id')}/challenge",
jwt=session.access_token,
xform=AuthMFAChallengeResponse.parse_obj,
)
else:
raise AuthSessionMissingError()
return self._request(
"POST",
f"factors/{params.get('factor_id')}/challenge",
jwt=session.access_token,
xform=AuthMFAChallengeResponse.parse_obj,
)
Comment on lines -538 to -546
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient._challenge refactored with the following changes:


def _challenge_and_verify(
self,
Expand Down Expand Up @@ -579,15 +578,15 @@ def _verify(self, params: MFAVerifyParams) -> AuthMFAVerifyResponse:
return response

def _unenroll(self, params: MFAUnenrollParams) -> AuthMFAUnenrollResponse:
session = self.get_session()
if not session:
if session := self.get_session():
return self._request(
"DELETE",
f"factors/{params.get('factor_id')}",
jwt=session.access_token,
xform=AuthMFAUnenrollResponse.parse_obj,
)
else:
raise AuthSessionMissingError()
return self._request(
"DELETE",
f"factors/{params.get('factor_id')}",
jwt=session.access_token,
xform=AuthMFAUnenrollResponse.parse_obj,
)
Comment on lines -582 to -590
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient._unenroll refactored with the following changes:


def _list_factors(self) -> AuthMFAListFactorsResponse:
response = self.get_user()
Expand Down