mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
fix/group (#3012)
* fix: app/dataset list private resource bug * fix: auth owner
This commit is contained in:
@@ -72,6 +72,12 @@ export const authAppByTmbId = async ({
|
||||
const isOwner = tmbPer.isOwner || String(app.tmbId) === String(tmbId);
|
||||
|
||||
const { Per } = await (async () => {
|
||||
if (isOwner) {
|
||||
return {
|
||||
Per: new AppPermission({ isOwner: true })
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
AppFolderTypeList.includes(app.type) ||
|
||||
app.inheritPermission === false ||
|
||||
|
@@ -64,6 +64,11 @@ export const authDatasetByTmbId = async ({
|
||||
|
||||
// get dataset permission or inherit permission from parent folder.
|
||||
const { Per } = await (async () => {
|
||||
if (isOwner) {
|
||||
return {
|
||||
Per: new DatasetPermission({ isOwner: true })
|
||||
};
|
||||
}
|
||||
if (
|
||||
dataset.type === DatasetTypeEnum.folder ||
|
||||
dataset.inheritPermission === false ||
|
||||
|
@@ -107,16 +107,11 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
|
||||
.limit(searchKey ? 20 : 1000)
|
||||
.lean(),
|
||||
MongoResourcePermission.find({
|
||||
$and: [
|
||||
{
|
||||
resourceType: PerResourceTypeEnum.app,
|
||||
teamId,
|
||||
resourceId: {
|
||||
$exists: true
|
||||
}
|
||||
},
|
||||
{ $or: [{ tmbId }, { groupId: { $in: myGroupIds } }] }
|
||||
]
|
||||
resourceType: PerResourceTypeEnum.app,
|
||||
teamId,
|
||||
resourceId: {
|
||||
$exists: true
|
||||
}
|
||||
}).lean()
|
||||
]);
|
||||
|
||||
@@ -143,7 +138,8 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
|
||||
per: tmbPer ?? groupPer ?? AppDefaultPermissionVal,
|
||||
isOwner: String(app.tmbId) === String(tmbId) || myPer.isOwner
|
||||
}),
|
||||
privateApp: !tmbPer && !groupPer
|
||||
privateApp:
|
||||
perList.filter((item) => String(item.resourceId) === String(app._id)).length <= 1
|
||||
};
|
||||
} else {
|
||||
const tmbPer = perList.find(
|
||||
@@ -160,14 +156,16 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
|
||||
per: tmbPer ?? groupPer ?? AppDefaultPermissionVal,
|
||||
isOwner: String(app.tmbId) === String(tmbId) || myPer.isOwner
|
||||
}),
|
||||
privateApp: !tmbPer && !groupPer
|
||||
privateApp:
|
||||
perList.filter((item) => String(item.resourceId) === String(app._id)).length <= 1
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
...app,
|
||||
permission: Per,
|
||||
privateApp: privateApp
|
||||
privateApp
|
||||
};
|
||||
})
|
||||
.filter((app) => app.permission.hasReadPer);
|
||||
|
@@ -92,16 +92,11 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
|
||||
})
|
||||
.lean(),
|
||||
MongoResourcePermission.find({
|
||||
$and: [
|
||||
{
|
||||
resourceType: PerResourceTypeEnum.dataset,
|
||||
teamId,
|
||||
resourceId: {
|
||||
$exists: true
|
||||
}
|
||||
},
|
||||
{ $or: [{ tmbId }, { groupId: { $in: myGroupIds } }] }
|
||||
]
|
||||
resourceType: PerResourceTypeEnum.dataset,
|
||||
teamId,
|
||||
resourceId: {
|
||||
$exists: true
|
||||
}
|
||||
}).lean()
|
||||
]);
|
||||
|
||||
@@ -127,7 +122,8 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
|
||||
per: tmbPer ?? groupPer ?? DatasetDefaultPermissionVal,
|
||||
isOwner: String(parentDataset.tmbId) === tmbId || myPer.isOwner
|
||||
}),
|
||||
privateDataset: !tmbPer && !groupPer
|
||||
privateDataset:
|
||||
perList.filter((item) => String(item.resourceId) === String(dataset._id)).length <= 1
|
||||
};
|
||||
} else {
|
||||
const tmbPer = perList.find(
|
||||
@@ -148,10 +144,12 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
|
||||
per: tmbPer ?? groupPer ?? DatasetDefaultPermissionVal,
|
||||
isOwner: String(dataset.tmbId) === tmbId || myPer.isOwner
|
||||
}),
|
||||
privateDataset: !tmbPer && !groupPer
|
||||
privateDataset:
|
||||
perList.filter((item) => String(item.resourceId) === String(dataset._id)).length <= 1
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
...dataset,
|
||||
permission: Per,
|
||||
|
Reference in New Issue
Block a user