mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-26 02:07:28 +08:00
fix:agent eval and doc file (#6158)
* agent eval * eval auth * html transofrm size * fix: test --------- Co-authored-by: xxyyh <2289112474@qq> Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import type { EvaluationSchemaType } from '@fastgpt/global/core/app/evaluation/t
|
||||
import type { AuthModeType } from '../type';
|
||||
import { MongoEvaluation } from '../../../core/app/evaluation/evalSchema';
|
||||
import { parseHeaderCert } from '../auth/common';
|
||||
import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
|
||||
|
||||
export const authEval = async ({
|
||||
evalId,
|
||||
@@ -21,7 +22,13 @@ export const authEval = async ({
|
||||
}> => {
|
||||
const { teamId, tmbId, isRoot } = await parseHeaderCert(props);
|
||||
|
||||
const evaluation = await MongoEvaluation.findById(evalId, 'tmbId').lean();
|
||||
const evaluation = await MongoEvaluation.findOne(
|
||||
{
|
||||
_id: evalId,
|
||||
teamId
|
||||
},
|
||||
'tmbId appId'
|
||||
).lean();
|
||||
if (!evaluation) {
|
||||
return Promise.reject('Evaluation not found');
|
||||
}
|
||||
@@ -34,28 +41,37 @@ export const authEval = async ({
|
||||
};
|
||||
}
|
||||
|
||||
// App read per
|
||||
if (per === ReadPermissionVal) {
|
||||
try {
|
||||
// App read per
|
||||
if (per === ReadPermissionVal) {
|
||||
await authAppByTmbId({
|
||||
tmbId,
|
||||
appId: evaluation.appId,
|
||||
per: ReadPermissionVal,
|
||||
isRoot
|
||||
});
|
||||
|
||||
return {
|
||||
teamId,
|
||||
tmbId,
|
||||
evaluation
|
||||
};
|
||||
}
|
||||
|
||||
// Write per
|
||||
await authAppByTmbId({
|
||||
tmbId,
|
||||
appId: evaluation.appId,
|
||||
per: ReadPermissionVal,
|
||||
per: ManagePermissionVal,
|
||||
isRoot
|
||||
});
|
||||
return {
|
||||
teamId,
|
||||
tmbId,
|
||||
evaluation
|
||||
};
|
||||
} catch (error) {
|
||||
// If app does not exist, allow operation (app was deleted, allow eval cleanup)
|
||||
if (error !== AppErrEnum.unExist) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Write per
|
||||
await authAppByTmbId({
|
||||
tmbId,
|
||||
appId: evaluation.appId,
|
||||
per: ManagePermissionVal,
|
||||
isRoot
|
||||
});
|
||||
return {
|
||||
teamId,
|
||||
tmbId,
|
||||
|
||||
Reference in New Issue
Block a user