From 8259949a7aa7c61df62149c099a1ac7e6bef8524 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sat, 24 Jan 2026 21:49:58 +0100 Subject: [PATCH] fix: update last_login timestamp on successful login The last_login field was never being updated. Now it gets set to the current UTC timestamp when a user successfully logs in. Co-Authored-By: Claude Opus 4.5 --- app/services/auth_service.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/auth_service.py b/app/services/auth_service.py index 6f1edd7f..380579e8 100644 --- a/app/services/auth_service.py +++ b/app/services/auth_service.py @@ -12,6 +12,7 @@ Note: Customer registration is handled by CustomerService. """ import logging +from datetime import UTC, datetime from typing import Any from sqlalchemy.orm import Session @@ -59,6 +60,10 @@ class AuthService: if not user.is_active: raise UserNotActiveException("User account is not active") + # Update last_login timestamp + user.last_login = datetime.now(UTC) + db.commit() + token_data = self.auth_manager.create_access_token(user) logger.info(f"User logged in: {user.username}")