Skip to content

Commit

Permalink
fix: errors in helpers and types
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Oct 19, 2021
1 parent c8daa2a commit 9870078
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gotrue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ def parse_response(response: Response, func: Callable[[Any], T]) -> T:

def parse_session_or_user(arg: Any) -> Union[Session, User]:
if "access_token" in arg:
Session.from_dict(arg)
return Session.from_dict(arg)
return User.from_dict(arg)
6 changes: 4 additions & 2 deletions gotrue/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from enum import Enum
from json import dumps
from time import time
from typing import Any, Callable, Dict, Optional, TypeVar

T = TypeVar("T")
Expand Down Expand Up @@ -174,7 +175,6 @@ def __post_init__(self) -> None:
self.email = parse_none(self.email, str)
self.password = parse_none(self.password, str)
self.email_change_token = parse_none(self.email_change_token, str)
self.data = parse_none(self.data, Any)

@staticmethod
def from_dict(data: dict) -> "UserAttributes":
Expand Down Expand Up @@ -204,8 +204,10 @@ class Session:

def __post_init__(self) -> None:
self.access_token = str(self.access_token)
self.expires_at = parse_none(self.expires_at, lambda x: int(str(x)))
self.expires_in = parse_none(self.expires_in, lambda x: int(str(x)))
self.expires_at = parse_none(self.expires_at, lambda x: int(str(x)))
if self.expires_in and not self.expires_at:
self.expires_at = round(time()) + self.expires_in
self.provider_token = parse_none(self.provider_token, str)
self.refresh_token = parse_none(self.refresh_token, str)
self.token_type = str(self.token_type)
Expand Down

0 comments on commit 9870078

Please sign in to comment.