@@ -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
|
||||
// };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user