Permission (#1687)

Co-authored-by: Archer <545436317@qq.com>
Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
This commit is contained in:
Archer
2024-06-04 17:52:00 +08:00
committed by GitHub
parent fcb915c988
commit 19c8a06d51
109 changed files with 2291 additions and 1091 deletions

View File

@@ -0,0 +1,26 @@
import { AuthResponseType } from '../type/auth.d';
import { AuthPropsType } from '../type/auth.d';
import { TeamTmbItemType } from '@fastgpt/global/support/user/team/type';
import { parseHeaderCert } from '../controller';
import { getTmbInfoByTmbId } from '../../user/team/controller';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
/* auth user role */
export async function authUserPer(props: AuthPropsType): Promise<
AuthResponseType & {
tmb: TeamTmbItemType;
}
> {
const result = await parseHeaderCert(props);
const tmb = await getTmbInfoByTmbId({ tmbId: result.tmbId });
if (!tmb.permission.checkPer(props.per)) {
return Promise.reject(TeamErrEnum.unAuthTeam);
}
return {
...result,
permission: tmb.permission,
tmb
};
}