fix: 修复开启仅允许已存在用户登录并且是第三方用户认证时报错instance没有id的问题

pull/8768/head
Jiangjie.Bai 2022-08-17 18:33:23 +08:00
parent 3ab634d88e
commit ccd6b01020
1 changed files with 3 additions and 0 deletions

View File

@ -147,6 +147,9 @@ def _clear_users_from_org(org, users):
@receiver(post_save, sender=User)
@on_transaction_commit
def on_user_created_set_default_org(sender, instance, created, **kwargs):
if not instance.id:
# 用户已被手动删除instance.orgs 时会使用 id 进行查找报错所以判断不存在id时不做处理
return
if not created:
return
if instance.orgs.count() > 0: