From 3a2294e53b68f85c8ca74378d70498357d0cb99d Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 25 Jun 2025 17:29:56 +0800 Subject: [PATCH] fix: chat user change error --- apps/common/log/log.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/common/log/log.py b/apps/common/log/log.py index d83027c4d..316c2b5e8 100644 --- a/apps/common/log/log.py +++ b/apps/common/log/log.py @@ -35,14 +35,17 @@ def _get_user(request): return { } - return { + user_info = { "id": str(user.id), "email": user.email, "phone": user.phone, "nick_name": user.nick_name, "username": user.username, - "role": user.role, } + # 如果是 User 模型且有 role 属性 + if hasattr(user, 'role'): + user_info['role'] = user.role + return user_info def _get_details(request):