mirror of https://github.com/jumpserver/jumpserver
[Update] 修改用户ViewSet序列类返回的admin_orgs(解决组织管理员登录的Bug)
parent
4994a4a387
commit
af9d42695f
|
@ -563,10 +563,10 @@ class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):
|
||||||
user_default = settings.STATIC_URL + "img/avatar/user.png"
|
user_default = settings.STATIC_URL + "img/avatar/user.png"
|
||||||
return user_default
|
return user_default
|
||||||
|
|
||||||
def admin_orgs(self):
|
# def admin_orgs(self):
|
||||||
from orgs.models import Organization
|
# from orgs.models import Organization
|
||||||
orgs = Organization.get_user_admin_or_audit_orgs(self)
|
# orgs = Organization.get_user_admin_or_audit_orgs(self)
|
||||||
return orgs
|
# return orgs
|
||||||
|
|
||||||
def avatar_url(self):
|
def avatar_url(self):
|
||||||
admin_default = settings.STATIC_URL + "img/avatar/admin.png"
|
admin_default = settings.STATIC_URL + "img/avatar/admin.png"
|
||||||
|
|
|
@ -23,7 +23,7 @@ class UserOrgSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
||||||
admin_orgs = UserOrgSerializer(many=True, read_only=True)
|
admin_or_audit_orgs = UserOrgSerializer(many=True, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
|
@ -34,7 +34,7 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
||||||
'comment', 'source', 'is_valid', 'is_expired',
|
'comment', 'source', 'is_valid', 'is_expired',
|
||||||
'is_active', 'created_by', 'is_first_login',
|
'is_active', 'created_by', 'is_first_login',
|
||||||
'date_password_last_updated', 'date_expired',
|
'date_password_last_updated', 'date_expired',
|
||||||
'avatar_url', 'admin_orgs',
|
'avatar_url', 'admin_or_audit_orgs',
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'password': {'write_only': True, 'required': False, 'allow_null': True, 'allow_blank': True},
|
'password': {'write_only': True, 'required': False, 'allow_null': True, 'allow_blank': True},
|
||||||
|
|
Loading…
Reference in New Issue