fix: log errors from expired session cleanup and token usage tracking
This commit is contained in:
@@ -109,7 +109,15 @@ func (s *authService) ValidateSession(ctx context.Context, sessionID string) (*d
|
||||
}
|
||||
|
||||
if session.ExpiresAt.Before(time.Now()) {
|
||||
_ = s.repo.DeleteSession(ctx, sessionID)
|
||||
if err := s.repo.DeleteSession(ctx, sessionID); err != nil {
|
||||
observability.Warn(
|
||||
"delete_expired_session_failed",
|
||||
"auth",
|
||||
"",
|
||||
map[string]any{"session_id": sessionID},
|
||||
err,
|
||||
)
|
||||
}
|
||||
return nil, errors.New("session expired")
|
||||
}
|
||||
|
||||
@@ -141,7 +149,15 @@ func (s *authService) ValidateAPIToken(ctx context.Context, token string) (*doma
|
||||
return nil, errors.New("token not found")
|
||||
}
|
||||
|
||||
_ = s.repo.TouchAPITokenLastUsedAt(ctx, t.ID)
|
||||
if err := s.repo.TouchAPITokenLastUsedAt(ctx, t.ID); err != nil {
|
||||
observability.Warn(
|
||||
"touch_api_token_last_used_at_failed",
|
||||
"auth",
|
||||
"",
|
||||
map[string]any{"token_id": t.ID},
|
||||
err,
|
||||
)
|
||||
}
|
||||
return s.repo.GetUserByID(ctx, t.UserID)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user