Skip to content

Commit aa87f97

Browse files
committed
fix: When other users download the public model, they cannot obtain the download data
1 parent 7e4e2e9 commit aa87f97

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/setting/serializers/provider_serializers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ def one(self, with_valid=False):
314314

315315
def one_meta(self, with_valid=False):
316316
if with_valid:
317-
self.is_valid(raise_exception=True)
317+
super().is_valid(raise_exception=True)
318+
model = QuerySet(Model).filter(id=self.data.get("id")).first()
319+
if model is None:
320+
raise AppApiException(500, _('Model does not exist'))
321+
if model.permission_type == 'PRIVATE' and str(model.user_id) != str(self.data.get("user_id")):
322+
raise Exception(_('No permission to use this model') + f"{model.name}")
318323
model = QuerySet(Model).get(id=self.data.get('id'), user_id=self.data.get('user_id'))
319324
return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type,
320325
'model_name': model.model_name,

0 commit comments

Comments
 (0)