perf: try to decrypt then origin value

dev
ibuler 2025-08-29 10:42:06 +08:00 committed by 老广
parent b9c60d856f
commit 28d5475d0f
1 changed files with 4 additions and 3 deletions

View File

@ -144,6 +144,10 @@ class EncryptMixin:
return value
plain_value = Encryptor(value).decrypt()
# 如果解密失败,则使用原来的值
if not plain_value:
plain_value = value
# 可能和Json mix所以要先解密再json
sp = super()
if hasattr(sp, "from_db_value"):
@ -166,9 +170,6 @@ class EncryptMixin:
class EncryptTextField(EncryptMixin, models.TextField):
description = _("Encrypt field using Secret Key")
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class EncryptCharField(EncryptMixin, models.CharField):
@staticmethod