fix: Use system session to handle

Use system session to handle token data and user

Change-Id: I3b0534c4a5097553e3689fcaf7915c4be6df1fe3
This commit is contained in:
Boxiang Zhu 2023-11-20 13:50:55 +08:00
parent 235f7fb286
commit 55adae48a5

View File

@ -49,13 +49,14 @@ router = APIRouter()
async def _get_default_project_id(
session: Session, region: str, user_id: Optional[str] = None
) -> Union[str, None]:
system_session = get_system_session()
if not user_id:
token = session.get_token()
token_data = await get_token_data(token, region, session)
token_data = await get_token_data(token, region, system_session)
_user_id = token_data["token"]["user"]["id"]
else:
_user_id = user_id
user = await get_user(_user_id, region, session)
user = await get_user(_user_id, region, system_session)
return getattr(user, "default_project_id", None)