From ca32b2205ac3c8e63c14e47e0f543d459d739802 Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 9 Jan 2026 22:37:06 +0000 Subject: [PATCH] option to disable auto-updating of user.last_login during user login --- baph/auth/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/baph/auth/__init__.py b/baph/auth/__init__.py index 279642e..265d2af 100644 --- a/baph/auth/__init__.py +++ b/baph/auth/__init__.py @@ -10,7 +10,7 @@ default_app_config = 'baph.auth.apps.AuthConfig' -def login(request, user): +def login(request, user, update_last_login=True): '''Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. @@ -26,8 +26,9 @@ def login(request, user): user = request.user # TODO: It would be nice to support different login methods, like signed # cookies. - user.last_login = datetime.now() - session.commit() + if update_last_login: + user.last_login = datetime.now() + session.commit() if SESSION_KEY in request.session: if request.session[SESSION_KEY] != user.id: