mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00

Co-authored-by: Archer <545436317@qq.com> Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
27 lines
788 B
TypeScript
27 lines
788 B
TypeScript
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
|
|
};
|
|
}
|