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 <noreply@anthropic.com>
This commit is contained in:
2026-01-24 21:49:58 +01:00
parent 3cd4781724
commit 8259949a7a

View File

@@ -12,6 +12,7 @@ Note: Customer registration is handled by CustomerService.
""" """
import logging import logging
from datetime import UTC, datetime
from typing import Any from typing import Any
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
@@ -59,6 +60,10 @@ class AuthService:
if not user.is_active: if not user.is_active:
raise UserNotActiveException("User account is not 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) token_data = self.auth_manager.create_access_token(user)
logger.info(f"User logged in: {user.username}") logger.info(f"User logged in: {user.username}")