mirror of https://github.com/jumpserver/jumpserver
perf: try to decrypt then origin value
parent
b9c60d856f
commit
28d5475d0f
|
@ -144,6 +144,10 @@ class EncryptMixin:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
plain_value = Encryptor(value).decrypt()
|
plain_value = Encryptor(value).decrypt()
|
||||||
|
|
||||||
|
# 如果解密失败,则使用原来的值
|
||||||
|
if not plain_value:
|
||||||
|
plain_value = value
|
||||||
# 可能和Json mix,所以要先解密,再json
|
# 可能和Json mix,所以要先解密,再json
|
||||||
sp = super()
|
sp = super()
|
||||||
if hasattr(sp, "from_db_value"):
|
if hasattr(sp, "from_db_value"):
|
||||||
|
@ -166,9 +170,6 @@ class EncryptMixin:
|
||||||
class EncryptTextField(EncryptMixin, models.TextField):
|
class EncryptTextField(EncryptMixin, models.TextField):
|
||||||
description = _("Encrypt field using Secret Key")
|
description = _("Encrypt field using Secret Key")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class EncryptCharField(EncryptMixin, models.CharField):
|
class EncryptCharField(EncryptMixin, models.CharField):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue