客服登录接口 KefuLoginView(/yonghu/kefujinru)已修复。
This commit is contained in:
@@ -6727,14 +6727,12 @@ class KefuLoginView(APIView):
|
||||
# 2. 获取客户端真实IP
|
||||
client_ip = self.get_client_ip(request)
|
||||
|
||||
# 3. 查询所有手机号匹配且类型为客服的用户
|
||||
# 注意:User 中需要有 user_type 字段,且值为 'kefu' 代表客服
|
||||
user_mains = User.query.filter(
|
||||
phone=phone,
|
||||
user_type='kefu' # 只查找客服账号
|
||||
).select_related('kefu_profile') # 预加载客服扩展表
|
||||
# 3. 查询该手机号下所有客服账号(GVSDSDK User 字段为 Phone,客服在 user_kefu 表)
|
||||
kefu_candidates = UserKefu.query.filter(
|
||||
user__Phone=phone,
|
||||
).select_related('user')
|
||||
|
||||
if not user_mains.exists():
|
||||
if not kefu_candidates.exists():
|
||||
logger.warning(f"登录失败,手机号不存在或非客服: {phone}, IP: {client_ip}")
|
||||
return Response({
|
||||
'code': 1,
|
||||
@@ -6742,19 +6740,14 @@ class KefuLoginView(APIView):
|
||||
'data': None
|
||||
}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# 4. 遍历所有匹配的用户,验证密码和二级密码
|
||||
# 4. 遍历所有匹配的客服账号,验证密码和二级密码
|
||||
target_user = None
|
||||
target_kefu = None
|
||||
|
||||
for user in user_mains:
|
||||
for kefu in kefu_candidates:
|
||||
user = kefu.user
|
||||
# 验证主密码(明文比较,按您的要求)
|
||||
if user.password != password:
|
||||
continue
|
||||
|
||||
# 检查是否存在客服扩展表
|
||||
try:
|
||||
kefu = user.kefu_profile
|
||||
except UserKefu.DoesNotExist:
|
||||
if user.UserPassword != password:
|
||||
continue
|
||||
|
||||
# 验证二级密码(明文比较)
|
||||
|
||||
Reference in New Issue
Block a user