Skip to content

Commit 98d829a

Browse files
committed
fix: Resource automatic authorization type error
1 parent b40c76d commit 98d829a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/system_manage/serializers/user_resource_permission.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from common.utils.split_model import group_by
2727
from knowledge.models import Knowledge
2828
from maxkb.conf import PROJECT_DIR
29+
from maxkb.settings import edition
2930
from models_provider.models import Model
3031
from system_manage.models import WorkspaceUserResourcePermission, AuthTargetType
3132
from tools.models import Tool
@@ -109,13 +110,14 @@ def auth_resource(self, resource_id: str):
109110
user_id = self.data.get('user_id')
110111
wurp = QuerySet(WorkspaceUserResourcePermission).filter(auth_target_type=auth_target_type,
111112
workspace_id=workspace_id).first()
112-
auth_type = wurp.auth_type if wurp else ResourceAuthType.RESOURCE_PERMISSION_GROUP
113+
auth_type = wurp.auth_type if wurp else (
114+
ResourceAuthType.RESOURCE_PERMISSION_GROUP if edition == 'CE' else ResourceAuthType.ROLE)
113115
# 自动授权给创建者
114116
WorkspaceUserResourcePermission(
115117
target=resource_id,
116118
auth_target_type=auth_target_type,
117119
permission_list=[ResourcePermission.VIEW,
118-
ResourcePermission.MANAGE] if auth_type == ResourceAuthType.RESOURCE_PERMISSION_GROUP else [
120+
ResourcePermission.MANAGE] if auth_type == ResourceAuthType.RESOURCE_PERMISSION_GROUP else [
119121
ResourcePermissionRole.ROLE],
120122
workspace_id=workspace_id,
121123
user_id=user_id,

0 commit comments

Comments
 (0)