mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00

* feat: change group owner api * pref: member/org/group * fix: member modal select clb * fix: search member when change owner
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
|
|
import { AuthModeType, AuthResponseType } from '../type';
|
|
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,
|
|
...props
|
|
}: {
|
|
orgIds?: string | string[];
|
|
} & AuthModeType): Promise<AuthResponseType> => {
|
|
const result = await authUserPer({
|
|
...props,
|
|
per: ManagePermissionVal
|
|
});
|
|
const { teamId, tmbId, isRoot, tmb } = result;
|
|
|
|
if (isRoot) {
|
|
return {
|
|
teamId,
|
|
tmbId,
|
|
userId: result.userId,
|
|
appId: result.appId,
|
|
apikey: result.apikey,
|
|
isRoot,
|
|
authType: result.authType,
|
|
permission: new TeamPermission({ isOwner: true })
|
|
};
|
|
}
|
|
|
|
if (tmb.permission.hasManagePer) {
|
|
return {
|
|
...result,
|
|
permission: tmb.permission
|
|
};
|
|
}
|
|
|
|
return Promise.reject(TeamErrEnum.unAuthTeam);
|
|
};
|