Files
FastGPT/test/datas/users.ts
Finley Ge 73451dbc64 fix: invite link (#4229)
* fix: invite link

* feat: create invite link and copy it directly
2025-03-27 10:05:02 +08:00

64 lines
1.5 KiB
TypeScript

import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
import { MongoUser } from '@fastgpt/service/support/user/schema';
import { MongoTeamMember } from '@fastgpt/service/support/user/team/teamMemberSchema';
import { MongoTeam } from '@fastgpt/service/support/user/team/teamSchema';
import { parseHeaderCertRet } from 'test/mocks/request';
export async function getRootUser(): Promise<parseHeaderCertRet> {
const rootUser = await MongoUser.create({
username: 'root',
password: '123456'
});
const team = await MongoTeam.create({
name: 'test team',
ownerId: rootUser._id
});
const tmb = await MongoTeamMember.create({
teamId: team._id,
userId: rootUser._id,
status: 'active'
});
return {
userId: rootUser._id,
apikey: '',
appId: '',
authType: AuthUserTypeEnum.token,
isRoot: true,
sourceName: undefined,
teamId: tmb?.teamId,
tmbId: tmb?._id
};
}
export async function getUser(username: string): Promise<parseHeaderCertRet> {
const user = await MongoUser.create({
username,
password: '123456'
});
const team = await MongoTeam.create({
name: 'test team',
ownerId: user._id
});
const tmb = await MongoTeamMember.create({
teamId: team._id,
userId: user._id,
status: 'active'
});
return {
userId: user._id,
apikey: '',
appId: '',
authType: AuthUserTypeEnum.token,
isRoot: false,
sourceName: undefined,
teamId: tmb?.teamId,
tmbId: tmb?._id
};
}