mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 16:33:49 +00:00
4.8.5 test fix (#1835)
* faq * perf: navbar name and fix dataset selector * feat: app tag * perf: icon * fix: update workflow bug * perf: dataset ui * perf: menu * fix: ts * fix: auth file and app list ui * app list * app list * perf: init api * update per * log level
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import { AuthResponseType } from '@fastgpt/global/support/permission/type';
|
||||
import { AuthModeType } from '../type';
|
||||
import { DatasetFileSchema } from '@fastgpt/global/core/dataset/type';
|
||||
import { parseHeaderCert } from '../controller';
|
||||
import { getFileById } from '../../../common/file/gridfs/controller';
|
||||
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
|
||||
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
|
||||
import { OwnerPermissionVal, ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { AuthPropsType, AuthResponseType } from '../type/auth';
|
||||
import { Permission } from '@fastgpt/global/support/permission/controller';
|
||||
|
||||
export async function authFile({
|
||||
fileId,
|
||||
per = 'owner',
|
||||
per = OwnerPermissionVal,
|
||||
...props
|
||||
}: AuthModeType & {
|
||||
}: AuthPropsType & {
|
||||
fileId: string;
|
||||
}): Promise<
|
||||
AuthResponseType & {
|
||||
@@ -29,14 +31,19 @@ export async function authFile({
|
||||
if (file.metadata?.teamId !== teamId) {
|
||||
return Promise.reject(CommonErrEnum.unAuthFile);
|
||||
}
|
||||
if (per === 'owner' && file.metadata?.tmbId !== tmbId) {
|
||||
|
||||
const permission = new Permission({
|
||||
per: ReadPermissionVal,
|
||||
isOwner: file.metadata?.tmbId === tmbId
|
||||
});
|
||||
|
||||
if (!permission.checkPer(per)) {
|
||||
return Promise.reject(CommonErrEnum.unAuthFile);
|
||||
}
|
||||
|
||||
return {
|
||||
...authRes,
|
||||
isOwner: per === 'owner',
|
||||
canWrite: per === 'owner',
|
||||
permission,
|
||||
file
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user