feat: update userapp views
All checks were successful
Build and Deploy LTY / build-and-deploy (push) Successful in 1h9m26s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
pmc 2026-04-21 18:48:04 +08:00
parent 90c6feb5a5
commit e57f681040

View File

@ -116,7 +116,8 @@ class MacAddressLoginView(APIView):
device = Device.objects.get(mac_address=mac_address)
# 检查设备是否已绑定给用户
user_device = UserDevice.objects.filter(device=device).first()
# 按绑定时间倒序取最新绑定者作为设备归属人——"后绑的挤掉先绑的"
user_device = UserDevice.objects.filter(device=device).order_by('-bound_at').first()
if not user_device:
logger.warning(f"Device not bound to any user: {mac_address}")
# 返回特定 code=4010让设备端可以识别"未绑定"状态