Skip to content

Commit

Permalink
fix: permission conflict after moving
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Info committed Jan 21, 2025
1 parent 3c97757 commit ceb4923
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projects/app/src/pages/api/core/app/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { authUserPer } from '@fastgpt/service/support/permission/user/auth';
import { TeamWritePermissionVal } from '@fastgpt/global/support/permission/user/constant';
import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
import { refreshSourceAvatar } from '@fastgpt/service/common/file/image/controller';
import { MongoResourcePermission } from '@fastgpt/service/support/permission/schema';

export type AppUpdateQuery = {
appId: string;
Expand Down Expand Up @@ -148,6 +149,12 @@ async function handler(req: ApiRequestProps<AppUpdateBody, AppUpdateQuery>) {
collaborators: parentClbsAndGroups,
session
});
} else {
// Not folder, delete all clb
await MongoResourcePermission.deleteMany(
{ resourceType: PerResourceTypeEnum.app, teamId: app.teamId, resourceId: app._id },
{ session }
);
}
return onUpdate(session);
});
Expand Down
7 changes: 7 additions & 0 deletions projects/app/src/pages/api/core/dataset/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { MongoDatasetTraining } from '@fastgpt/service/core/dataset/training/sch
import { MongoDatasetCollection } from '@fastgpt/service/core/dataset/collection/schema';
import { addDays } from 'date-fns';
import { refreshSourceAvatar } from '@fastgpt/service/common/file/image/controller';
import { MongoResourcePermission } from '@fastgpt/service/support/permission/schema';

export type DatasetUpdateQuery = {};
export type DatasetUpdateResponse = any;
Expand Down Expand Up @@ -175,6 +176,12 @@ async function handler(
collaborators: parentClbsAndGroups,
session
});
} else {
// Not folder, delete all clb
await MongoResourcePermission.deleteMany(
{ resourceId: id, teamId: dataset.teamId, resourceType: PerResourceTypeEnum.dataset },
{ session }
);
}
return onUpdate(session);
} else {
Expand Down

0 comments on commit ceb4923

Please sign in to comment.