mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 00:56:26 +00:00

* feat: team permission refine (#4402) * chore: team permission extend * feat: manage team permission * chore: api auth * fix: i18n * feat: add initv493 * fix: test, org auth manager * test: app test for refined permission * update init sh * fix: add/remove manage permission (#4427) * fix: add/remove manage permission * fix: github action fastgpt-test * fix: mock create model * fix: team write permission * fix: ts * account permission --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
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 { TeamManagePermissionVal } from '@fastgpt/global/support/permission/user/constant';
|
|
|
|
/*
|
|
Team manager can control org
|
|
*/
|
|
export const authOrgMember = async ({
|
|
orgIds,
|
|
...props
|
|
}: {
|
|
orgIds?: string | string[];
|
|
} & AuthModeType): Promise<AuthResponseType> => {
|
|
const result = await authUserPer({
|
|
...props,
|
|
per: TeamManagePermissionVal
|
|
});
|
|
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);
|
|
};
|