v4.6.2-alpah (#511)

This commit is contained in:
Archer
2023-11-24 15:29:43 +08:00
committed by GitHub
parent 60f752629f
commit 9cb4280a16
208 changed files with 5396 additions and 3500 deletions

View File

@@ -6,6 +6,8 @@ import { TeamMemberRoleEnum } from '@fastgpt/global/support/user/team/constant';
import { MongoPlugin } from '../../../core/plugin/schema';
import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin';
import { PluginItemSchema } from '@fastgpt/global/core/plugin/type';
import { splitCombinePluginId } from '../../../core/plugin/controller';
import { PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
export async function authPluginCrud({
id,
@@ -54,3 +56,29 @@ export async function authPluginCrud({
canWrite
};
}
export async function authPluginCanUse({
id,
teamId,
tmbId
}: {
id: string;
teamId: string;
tmbId: string;
}) {
const { type, pluginId } = await splitCombinePluginId(id);
if (type === PluginTypeEnum.community) {
return true;
}
if (type === PluginTypeEnum.personal) {
const { role } = await getTeamInfoByTmbId({ tmbId });
const plugin = await MongoPlugin.findOne({ _id: pluginId, teamId });
if (!plugin) {
return Promise.reject(PluginErrEnum.unExist);
}
}
return true;
}