mirror of https://github.com/jumpserver/jumpserver
[Update] 修改用户profile序列类
parent
229c782157
commit
1845821f6c
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
@ -199,17 +200,24 @@ class UserProfileSerializer(UserSerializer):
|
||||||
public_key_hash_md5 = serializers.CharField(
|
public_key_hash_md5 = serializers.CharField(
|
||||||
source='get_public_key_hash_md5', required=False, read_only=True, max_length=128
|
source='get_public_key_hash_md5', required=False, read_only=True, max_length=128
|
||||||
)
|
)
|
||||||
|
MFA_LEVEL_CHOICES = (
|
||||||
|
(0, _('Disable')),
|
||||||
|
(1, _('Enable')),
|
||||||
|
)
|
||||||
|
mfa_level = serializers.ChoiceField(choices=MFA_LEVEL_CHOICES, label=_('MFA'))
|
||||||
|
guide_url = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta(UserSerializer.Meta):
|
class Meta(UserSerializer.Meta):
|
||||||
fields = UserSerializer.Meta.fields + [
|
fields = UserSerializer.Meta.fields + [
|
||||||
'public_key_comment', 'public_key_hash_md5', 'admin_or_audit_orgs', 'current_org_roles'
|
'public_key_comment', 'public_key_hash_md5', 'admin_or_audit_orgs', 'current_org_roles',
|
||||||
|
'guide_url'
|
||||||
]
|
]
|
||||||
extra_kwargs = dict(UserSerializer.Meta.extra_kwargs)
|
extra_kwargs = dict(UserSerializer.Meta.extra_kwargs)
|
||||||
extra_kwargs.update({
|
extra_kwargs.update({
|
||||||
'name': {'read_only': True, 'max_length': 128},
|
'name': {'read_only': True, 'max_length': 128},
|
||||||
'username': {'read_only': True, 'max_length': 128},
|
'username': {'read_only': True, 'max_length': 128},
|
||||||
'email': {'read_only': True},
|
'email': {'read_only': True},
|
||||||
'mfa_level': {'read_only': True},
|
# 'mfa_level': {'read_only': True},
|
||||||
'source': {'read_only': True},
|
'source': {'read_only': True},
|
||||||
'is_valid': {'read_only': True},
|
'is_valid': {'read_only': True},
|
||||||
'is_active': {'read_only': True},
|
'is_active': {'read_only': True},
|
||||||
|
@ -230,6 +238,10 @@ class UserProfileSerializer(UserSerializer):
|
||||||
fields.remove('public_key')
|
fields.remove('public_key')
|
||||||
extra_kwargs.pop('public_key', None)
|
extra_kwargs.pop('public_key', None)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_guide_url(obj):
|
||||||
|
return settings.USER_GUIDE_URL
|
||||||
|
|
||||||
|
|
||||||
class UserUpdatePasswordSerializer(serializers.ModelSerializer):
|
class UserUpdatePasswordSerializer(serializers.ModelSerializer):
|
||||||
old_password = serializers.CharField(required=True, max_length=128, write_only=True)
|
old_password = serializers.CharField(required=True, max_length=128, write_only=True)
|
||||||
|
|
Loading…
Reference in New Issue