From 5f839a47b6247a824cf8e83025d24f12a30b3050 Mon Sep 17 00:00:00 2001 From: ZTatman Date: Mon, 5 Oct 2026 15:09:02 -0400 Subject: [PATCH] refactor(auth): drop per-request session write, keep last_seen_at for sliding window --- web/app/auth/session.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/app/auth/session.py b/web/app/auth/session.py index 51a22c9..f9b0209 100644 --- a/web/app/auth/session.py +++ b/web/app/auth/session.py @@ -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