Skip to content

Commit

Permalink
revert changes to parse_auth_response
Browse files Browse the repository at this point in the history
  • Loading branch information
abyesilyurt committed Feb 8, 2024
1 parent 7810bbd commit face521
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gotrue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
GenerateLinkProperties,
GenerateLinkResponse,
SSOResponse,
Session,
User,
UserResponse,
)
Expand Down Expand Up @@ -57,7 +58,19 @@ def model_dump_json(model: BaseModel) -> str:


def parse_auth_response(data: Any) -> AuthResponse:
return model_validate(AuthResponse, data)
session: Union[Session, None] = None
if (
"access_token" in data
and "refresh_token" in data
and "expires_in" in data
and data["access_token"]
and data["refresh_token"]
and data["expires_in"]
):
session = model_validate(Session, data)
user_data = data.get("user", data)
user = model_validate(User, user_data) if user_data else None
return AuthResponse(session=session, user=user)


def parse_auth_otp_response(data: Any) -> AuthOtpResponse:
Expand Down

0 comments on commit face521

Please sign in to comment.