Set last seen and increment visits during registration, not only on authentication.

This commit is contained in:
2026-02-10 21:25:20 +00:00
parent d8876d9202
commit 3ca784dc3c
2 changed files with 16 additions and 14 deletions
+12
View File
@@ -309,6 +309,18 @@ class Session(msgspec.Struct, dict=True):
"expiry": self.expiry.isoformat(),
}
def store(self) -> None:
"""Store this session in the database and record a visit.
Updates user.last_seen and user.visits. Must be called inside
a database transaction.
"""
_data = db.data()
_data.sessions[self.key] = self
now = datetime.now(UTC)
_data.users[self.user_uuid].last_seen = now
_data.users[self.user_uuid].visits += 1
@classmethod
def create(
cls,