Skip to content

Commit ee1c863

Browse files
committed
refactor(dashboard): Use new SessionInfo class instead of SessionInformationResult
1 parent 3d2a94a commit ee1c863

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

supertokens_python/recipe/dashboard/api/userdetails/user_sessions_get.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
)
99
from supertokens_python.recipe.session.interfaces import SessionInformationResult
1010

11-
from ...interfaces import APIInterface, APIOptions, UserSessionsGetAPIResponse
11+
from ...interfaces import (
12+
APIInterface,
13+
APIOptions,
14+
SessionInfo,
15+
UserSessionsGetAPIResponse,
16+
)
1217

1318

1419
async def handle_sessions_get(
@@ -20,13 +25,13 @@ async def handle_sessions_get(
2025
raise_bad_input_exception("Missing required parameter 'userId'")
2126

2227
session_handles = await get_all_session_handles_for_user(user_id)
23-
sessions: List[Optional[SessionInformationResult]] = [None for _ in session_handles]
28+
sessions: List[Optional[SessionInfo]] = [None for _ in session_handles]
2429

2530
async def call_(i: int, session_handle: str):
2631
try:
2732
session_response = await get_session_information(session_handle)
2833
if session_response is not None:
29-
sessions[i] = session_response
34+
sessions[i] = SessionInfo(session_response)
3035
except Exception:
3136
sessions[i] = None
3237

supertokens_python/recipe/dashboard/interfaces.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from abc import ABC, abstractmethod
1717
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Optional, Union
1818

19+
from supertokens_python.recipe.session.interfaces import SessionInformationResult
1920
from supertokens_python.types import User
2021

2122
from ...supertokens import AppInfo
@@ -24,7 +25,16 @@
2425

2526
if TYPE_CHECKING:
2627
from supertokens_python.framework import BaseRequest, BaseResponse
27-
from supertokens_python.recipe.session.interfaces import SessionInformationResult
28+
29+
30+
class SessionInfo:
31+
def __init__(self, info: SessionInformationResult) -> None:
32+
self.session_handle = info.session_handle
33+
self.user_id = info.user_id
34+
self.session_data = info.session_data
35+
self.expiry = info.expiry
36+
self.access_token_payload = info.access_token_payload
37+
self.time_created = info.time_created
2838

2939

3040
class RecipeInterface(ABC):
@@ -142,7 +152,7 @@ def to_json(self) -> Dict[str, Any]:
142152
class UserSessionsGetAPIResponse(APIResponse):
143153
status: str = "OK"
144154

145-
def __init__(self, sessions: List[SessionInformationResult]):
155+
def __init__(self, sessions: List[SessionInfo]):
146156
self.sessions = [
147157
{
148158
"accessTokenPayload": s.access_token_payload,

supertokens_python/recipe/dashboard/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def from_dict(
108108
return self
109109

110110
def to_json(self) -> Dict[str, Any]:
111-
user_json = {
111+
user_json: Dict[str, Any] = {
112112
"id": self.user_id,
113113
"timeJoined": self.time_joined,
114114
}

0 commit comments

Comments
 (0)