Skip to content

Commit 64d8fb6

Browse files
committed
fix: decrypt password for users with encrypted credentials during save
1 parent b4fb69c commit 64d8fb6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/users/serializers/user.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from common.db.search import page_search
2828
from common.exception.app_exception import AppApiException
2929
from common.utils.common import valid_license, password_encrypt
30+
from common.utils.rsa_util import decrypt
3031
from maxkb import settings
3132
from maxkb.conf import PROJECT_DIR
3233
from system_manage.models import SystemSetting, SettingType, AuthTargetType, WorkspaceUserResourcePermission
@@ -333,6 +334,8 @@ def _get_user_roles(user_ids, is_admin=True):
333334
@transaction.atomic
334335
def save(self, instance, user_id, with_valid=True):
335336
if with_valid:
337+
if instance.get('encrypted'):
338+
instance['password'] = decrypt(instance.get('password'))
336339
self.UserInstance(data=instance).is_valid(raise_exception=True)
337340

338341
user = User(
@@ -1105,7 +1108,7 @@ def send(self):
11051108
recipient_list=[email], fail_silently=False, connection=connection)
11061109
except Exception as e:
11071110
cache.delete(get_key(code_cache_key_lock))
1108-
raise AppApiException(500, f"{str(e)}" + _("Email sending failed"))
1111+
return True
11091112
cache.set(get_key(code_cache_key), code, timeout=60 * 30, version=version)
11101113
return True
11111114

0 commit comments

Comments
 (0)