Skip to content

Commit

Permalink
api.user_manager: add username in log messages
Browse files Browse the repository at this point in the history
Show the username in log messages in addition to the user ID.  This
makes it much easier to follow the logs when checking user activity.

Signed-off-by: Guillaume Tucker <[email protected]>
  • Loading branch information
gctucker authored and JenySadadia committed Nov 16, 2023
1 parent bf2c214 commit 8afe94f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, user_db: BaseUserDatabase[User, PydanticObjectId],
async def on_after_register(self, user: User,
request: Optional[Request] = None):
"""Handler to execute after successful user registration"""
print(f"User {user.id} has registered.")
print(f"User {user.id} {user.username} has registered.")

async def on_after_request_verify(self, user: User, token: str,
request: Optional[Request] = None):
Expand All @@ -55,7 +55,7 @@ async def on_after_request_verify(self, user: User, token: str,
async def on_after_verify(self, user: User,
request: Optional[Request] = None):
"""Handler to execute after successful user verification"""
print(f"Verification successful for user {user.id}")
print(f"Verification successful for user {user.id} {user.username}")
template = self._template_env.get_template(
"email-verification-successful.jinja2")
subject = "Email verification successful for KernelCI API account"
Expand All @@ -67,7 +67,7 @@ async def on_after_verify(self, user: User,
async def on_after_login(self, user: User,
request: Optional[Request] = None):
"""Handler to execute after successful user login"""
print(f"User {user.id} logged in.")
print(f"User {user.id} {user.username} logged in.")

async def on_after_forgot_password(self, user: User, token: str,
request: Optional[Request] = None):
Expand All @@ -82,7 +82,7 @@ async def on_after_forgot_password(self, user: User, token: str,
async def on_after_reset_password(self, user: User,
request: Optional[Request] = None):
"""Handler to execute after successful password reset"""
print(f"User {user.id} has reset their password.")
print(f"User {user.id} {user.username} has reset their password.")
template = self._template_env.get_template(
"reset-password-successful.jinja2")
subject = "Password reset successful for KernelCI API account"
Expand All @@ -94,17 +94,17 @@ async def on_after_reset_password(self, user: User,
async def on_after_update(self, user: User, update_dict: Dict[str, Any],
request: Optional[Request] = None):
"""Handler to execute after successful user update"""
print(f"User {user.id} has been updated.")
print(f"User {user.id} {user.username} has been updated.")

async def on_before_delete(self, user: User,
request: Optional[Request] = None):
"""Handler to execute before user delete."""
print(f"User {user.id} is going to be deleted.")
print(f"User {user.id} {user.username} is going to be deleted.")

async def on_after_delete(self, user: User,
request: Optional[Request] = None):
"""Handler to execute after user delete."""
print(f"User {user.id} is successfully deleted.")
print(f"User {user.id} {user.username} was successfully deleted.")

async def authenticate(
self, credentials: OAuth2PasswordRequestForm
Expand Down

0 comments on commit 8afe94f

Please sign in to comment.