2021-07-08 06:23:18 +00:00
|
|
|
from django.dispatch import receiver
|
2022-07-15 10:03:32 +00:00
|
|
|
from django.db.models.signals import pre_save
|
2021-07-08 06:23:18 +00:00
|
|
|
|
|
|
|
from common.utils import get_logger
|
2022-07-15 10:03:32 +00:00
|
|
|
from ..models import Account
|
2021-07-08 06:23:18 +00:00
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
|
2022-07-15 10:03:32 +00:00
|
|
|
@receiver(pre_save, sender=Account)
|
|
|
|
def on_account_pre_create(sender, instance, **kwargs):
|
2022-09-07 12:24:48 +00:00
|
|
|
# Todo: 是否只有更改密码的时候才有版本增加, bitwarden 只有再改密码的时候,
|
|
|
|
# 才会有版本,代表的是 password_version
|
2021-07-08 06:23:18 +00:00
|
|
|
# 升级版本号
|
2021-08-19 03:13:36 +00:00
|
|
|
instance.version += 1
|
2021-07-15 02:08:50 +00:00
|
|
|
# 即使在 root 组织也不怕
|
|
|
|
instance.org_id = instance.asset.org_id
|