fix(sessions): cannot find current session
This commit is contained in:
@@ -31,6 +31,8 @@ async def get_sessions(
|
|||||||
geoip: GeoIPService,
|
geoip: GeoIPService,
|
||||||
):
|
):
|
||||||
current_user, token = user_and_token
|
current_user, token = user_and_token
|
||||||
|
current = 0
|
||||||
|
|
||||||
sessions = (
|
sessions = (
|
||||||
await session.exec(
|
await session.exec(
|
||||||
select(
|
select(
|
||||||
@@ -40,10 +42,16 @@ async def get_sessions(
|
|||||||
.order_by(col(LoginSession.created_at).desc())
|
.order_by(col(LoginSession.created_at).desc())
|
||||||
)
|
)
|
||||||
).all()
|
).all()
|
||||||
|
resp = []
|
||||||
|
for s in sessions:
|
||||||
|
resp.append(LoginSessionResp.from_db(s, geoip))
|
||||||
|
if s.token_id == token.id:
|
||||||
|
current = s.id
|
||||||
|
|
||||||
return SessionsResp(
|
return SessionsResp(
|
||||||
total=len(sessions),
|
total=len(sessions),
|
||||||
current=token.id,
|
current=current,
|
||||||
sessions=[LoginSessionResp.from_db(s, geoip) for s in sessions],
|
sessions=resp,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user