perf: Team org ui (#3499)

* perf: org ui

* perf: org ui
This commit is contained in:
Archer
2024-12-30 20:49:11 +08:00
committed by archer
parent 1fc77a126a
commit efecfd44c3
21 changed files with 505 additions and 563 deletions

View File

@@ -1,20 +1,24 @@
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
import { AuthModeType, AuthResponseType } from '../type';
import { parseHeaderCert } from '../controller';
import { getTmbInfoByTmbId } from '../../user/team/controller';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
import { authUserPer } from '../user/auth';
import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant';
/*
Team manager can control org
*/
export const authOrgMember = async ({
orgIds,
req,
authToken = false,
authRoot = false,
authApiKey = false
...props
}: {
orgIds: string | string[];
} & AuthModeType): Promise<AuthResponseType> => {
const result = await parseHeaderCert({ req, authToken, authApiKey, authRoot });
const { teamId, tmbId, isRoot } = result;
const result = await authUserPer({
...props,
per: ManagePermissionVal
});
const { teamId, tmbId, isRoot, tmb } = result;
if (isRoot) {
return {
teamId,
@@ -28,13 +32,6 @@ export const authOrgMember = async ({
};
}
if (!Array.isArray(orgIds)) {
orgIds = [orgIds];
}
// const promises = orgIds.map((orgId) => getOrgMemberRole({ orgId, tmbId }));
const tmb = await getTmbInfoByTmbId({ tmbId });
if (tmb.permission.hasManagePer) {
return {
...result,
@@ -43,16 +40,4 @@ export const authOrgMember = async ({
}
return Promise.reject(TeamErrEnum.unAuthTeam);
// const targetRole = OrgMemberRole[role];
// for (const orgRole of orgRoles) {
// if (!orgRole || checkOrgRole(orgRole, targetRole)) {
// return Promise.reject(TeamErrEnum.unAuthTeam);
// }
// }
// return {
// ...result,
// permission: tmb.permission
// };
};