mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-21 04:17:59 +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()
|
||||
if sess is None:
|
||||
return None
|
||||
# Track activity whenever a valid cookie is used, then refresh the related
|
||||
# user so route handlers can safely access sess.user.
|
||||
sess.last_seen_at = now
|
||||
await db.commit()
|
||||
await db.refresh(sess, attribute_names=["user"])
|
||||
# sess.user is eagerly loaded via selectinload and the sessionmaker uses
|
||||
# expire_on_commit=False, so it stays accessible without a refresh. last_seen_at
|
||||
# is intentionally not updated here to keep auth reads free of writes; it is
|
||||
# reserved for a future sliding-window expiry feature.
|
||||
return sess
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue