mirror of https://github.com/jumpserver/jumpserver
fix: system org
parent
ae94648e80
commit
11f6fe0bf9
|
@ -38,7 +38,7 @@ class OrgSerializer(ModelSerializer):
|
||||||
class CurrentOrgSerializer(ModelSerializer):
|
class CurrentOrgSerializer(ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Organization
|
model = Organization
|
||||||
fields = ['id', 'name', 'is_default', 'is_root', 'comment']
|
fields = ['id', 'name', 'is_default', 'is_root', 'is_system', 'comment']
|
||||||
|
|
||||||
|
|
||||||
class CurrentOrgDefault:
|
class CurrentOrgDefault:
|
||||||
|
|
|
@ -24,13 +24,13 @@ def get_org_from_request(request):
|
||||||
# 其次session
|
# 其次session
|
||||||
if not oid:
|
if not oid:
|
||||||
oid = request.session.get("oid")
|
oid = request.session.get("oid")
|
||||||
|
|
||||||
if oid and oid.lower() == 'default':
|
if oid and oid.lower() == 'default':
|
||||||
return Organization.default()
|
return Organization.default()
|
||||||
|
|
||||||
if oid and oid.lower() == 'root':
|
if oid and oid.lower() == 'root':
|
||||||
return Organization.root()
|
return Organization.root()
|
||||||
|
|
||||||
if oid and oid.lower() == 'system':
|
if oid and oid.lower() == 'system':
|
||||||
return Organization.system()
|
return Organization.system()
|
||||||
|
|
||||||
|
@ -39,14 +39,14 @@ def get_org_from_request(request):
|
||||||
if org and org.internal:
|
if org and org.internal:
|
||||||
# 内置组织直接返回
|
# 内置组织直接返回
|
||||||
return org
|
return org
|
||||||
|
|
||||||
if not settings.XPACK_ENABLED:
|
if not settings.XPACK_ENABLED:
|
||||||
# 社区版用户只能使用默认组织
|
# 社区版用户只能使用默认组织
|
||||||
return Organization.default()
|
return Organization.default()
|
||||||
|
|
||||||
if not org and request.user.is_authenticated:
|
if not org and request.user.is_authenticated:
|
||||||
# 企业版用户优先从自己有权限的组织中获取
|
# 企业版用户优先从自己有权限的组织中获取
|
||||||
org = request.user.orgs.first()
|
org = request.user.orgs.exclude(id=Organization.SYSTEM_ID).first()
|
||||||
|
|
||||||
if not org:
|
if not org:
|
||||||
org = Organization.default()
|
org = Organization.default()
|
||||||
|
|
|
@ -12,6 +12,7 @@ class UserOrgSerializer(serializers.Serializer):
|
||||||
id = serializers.CharField()
|
id = serializers.CharField()
|
||||||
name = serializers.CharField()
|
name = serializers.CharField()
|
||||||
is_default = serializers.BooleanField(read_only=True)
|
is_default = serializers.BooleanField(read_only=True)
|
||||||
|
is_system = serializers.BooleanField(read_only=True)
|
||||||
is_root = serializers.BooleanField(read_only=True)
|
is_root = serializers.BooleanField(read_only=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue