Commit 005272cd authored by Bai's avatar Bai

[Update] 更新系统用户认证信息private_key转换

parent f88cb3da
# -*- coding: utf-8 -*-
#
import io
import os
import uuid
from hashlib import md5
......@@ -76,6 +77,14 @@ class AssetUser(OrgModelMixin):
i = '-'.join(str(self.id).split('-')[:3])
return i
def get_private_key(self):
if not self.private_key_obj:
return None
string_io = io.StringIO()
self.private_key_obj.write_private_key(string_io)
private_key = string_io.getvalue()
return private_key
def get_related_assets(self):
assets = self.assets.all()
return assets
......
......@@ -123,6 +123,7 @@ class SystemUserAuthSerializer(AuthSerializer):
"""
系统用户认证信息
"""
private_key = serializers.SerializerMethodField()
class Meta:
model = SystemUser
......@@ -131,6 +132,10 @@ class SystemUserAuthSerializer(AuthSerializer):
"login_mode", "password", "private_key",
]
@staticmethod
def get_private_key(obj):
return obj.get_private_key()
class SystemUserSimpleSerializer(serializers.ModelSerializer):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment