mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-22 21:07:57 +00:00
refactor(auth): drop per-request session write, keep last_seen_at for sliding window
This commit is contained in:
parent
c34e533c81
commit
5f839a47b6
1 changed files with 4 additions and 5 deletions
|
|
@ -71,11 +71,10 @@ async def lookup_session(
|
||||||
sess = result.scalar_one_or_none()
|
sess = result.scalar_one_or_none()
|
||||||
if sess is None:
|
if sess is None:
|
||||||
return None
|
return None
|
||||||
# Track activity whenever a valid cookie is used, then refresh the related
|
# sess.user is eagerly loaded via selectinload and the sessionmaker uses
|
||||||
# user so route handlers can safely access sess.user.
|
# expire_on_commit=False, so it stays accessible without a refresh. last_seen_at
|
||||||
sess.last_seen_at = now
|
# is intentionally not updated here to keep auth reads free of writes; it is
|
||||||
await db.commit()
|
# reserved for a future sliding-window expiry feature.
|
||||||
await db.refresh(sess, attribute_names=["user"])
|
|
||||||
return sess
|
return sess
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue