follow changes to auth api on 2023-05-22.
This commit is contained in:
parent
837f035bc1
commit
9d62d3fb6a
@ -11,8 +11,9 @@ from mdrsclient.models import Token, User
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class UserAuthResponse(Token):
|
||||
laboratory: str
|
||||
lab_id: int
|
||||
is_reviewer: bool | None = None
|
||||
laboratory: str | None = None
|
||||
lab_id: int | None = None
|
||||
|
||||
|
||||
class UserApi(BaseApi):
|
||||
@ -28,7 +29,9 @@ class UserApi(BaseApi):
|
||||
self._raise_response_error(response)
|
||||
obj = parse_obj_as(UserAuthResponse, response.json())
|
||||
token = Token(access=obj.access, refresh=obj.refresh)
|
||||
user = User(id=token.user_id, username=username, laboratory_id=obj.lab_id, laboratory=obj.laboratory)
|
||||
laboratory_ids = [obj.lab_id] if obj.lab_id is not None else []
|
||||
is_reviewer = obj.is_reviewer if obj.is_reviewer is not None else False
|
||||
user = User(id=token.user_id, username=username, laboratory_ids=laboratory_ids, is_reviewer=is_reviewer)
|
||||
return (user, token)
|
||||
|
||||
def refresh(self, token: Token) -> Token:
|
||||
|
@ -46,5 +46,5 @@ class Token:
|
||||
class User:
|
||||
id: int
|
||||
username: str
|
||||
laboratory_id: int
|
||||
laboratory: str
|
||||
laboratory_ids: list[int]
|
||||
is_reviewer: bool
|
||||
|
Loading…
Reference in New Issue
Block a user