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:
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user