fix(sessions): cannot find current session

This commit is contained in:
MingxuanGame
2025-10-08 05:24:52 +00:00
parent 3dd74fc703
commit e2f3c5099f

View File

@@ -31,6 +31,8 @@ async def get_sessions(
geoip: GeoIPService,
):
current_user, token = user_and_token
current = 0
sessions = (
await session.exec(
select(
@@ -40,10 +42,16 @@ async def get_sessions(
.order_by(col(LoginSession.created_at).desc())
)
).all()
resp = []
for s in sessions:
resp.append(LoginSessionResp.from_db(s, geoip))
if s.token_id == token.id:
current = s.id
return SessionsResp(
total=len(sessions),
current=token.id,
sessions=[LoginSessionResp.from_db(s, geoip) for s in sessions],
current=current,
sessions=resp,
)