mirror of https://github.com/jumpserver/jumpserver
parent
9cfbbe9157
commit
8aa21db52b
|
@ -6,7 +6,7 @@ from rest_framework import serializers
|
|||
|
||||
from common.mixins import CommonBulkSerializerMixin
|
||||
from common.validators import PhoneValidator
|
||||
from common.utils import pretty_string
|
||||
from common.utils import pretty_string, get_logger
|
||||
from common.drf.fields import EncryptedField
|
||||
from rbac.builtin import BuiltinRole
|
||||
from rbac.permissions import RBACPermission
|
||||
|
@ -19,6 +19,8 @@ __all__ = [
|
|||
'InviteSerializer', 'ServiceAccountSerializer',
|
||||
]
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
class RolesSerializerMixin(serializers.Serializer):
|
||||
system_roles = serializers.ManyRelatedField(
|
||||
|
@ -198,8 +200,10 @@ class UserSerializer(RolesSerializerMixin, CommonBulkSerializerMixin, serializer
|
|||
if not disallow_fields:
|
||||
return attrs
|
||||
# 用户自己不能更新自己的一些字段
|
||||
error = _('User cannot self-update fields: {}').format(disallow_fields)
|
||||
raise serializers.ValidationError(error)
|
||||
logger.debug('Disallow update self fields: %s', disallow_fields)
|
||||
for field in disallow_fields:
|
||||
attrs.pop(field, None)
|
||||
return attrs
|
||||
|
||||
def validate(self, attrs):
|
||||
attrs = self.check_disallow_self_update_fields(attrs)
|
||||
|
|
Loading…
Reference in New Issue