This commit is contained in:
Archer
2023-11-09 09:46:57 +08:00
committed by GitHub
parent 661ee79943
commit 8bb5588305
402 changed files with 9899 additions and 5967 deletions

View File

@@ -0,0 +1,36 @@
import { getDatasetPgData } from '@/service/core/dataset/data/controller';
import { PgDataItemType } from '@fastgpt/global/core/dataset/type';
import { AuthResponseType } from '@fastgpt/global/support/permission/type';
import { authDatasetCollection } from '@fastgpt/service/support/permission/auth/dataset';
import { parseHeaderCert } from '@fastgpt/service/support/permission/controller';
import { AuthModeType } from '@fastgpt/service/support/permission/type';
export async function authDatasetData({
dataId,
...props
}: AuthModeType & {
dataId: string;
}): Promise<
AuthResponseType & {
datasetData: PgDataItemType;
}
> {
const result = await parseHeaderCert(props);
const { tmbId } = result;
// get pg data
const datasetData = await getDatasetPgData({ id: dataId });
const isOwner = String(datasetData.tmbId) === tmbId;
// data has the same permissions as collection
const { canWrite } = await authDatasetCollection({
...props,
collectionId: datasetData.collectionId
});
return {
...result,
datasetData,
isOwner,
canWrite
};
}