-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
393 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,38 @@ | ||
import type { OrgMemberRole } from './constant'; | ||
|
||
type postCreateOrgData = { | ||
export type postCreateOrgData = { | ||
name: string; | ||
parentId: string; | ||
description?: string; | ||
avatar?: string; | ||
}; | ||
|
||
type putUpdateOrgMembersData = { | ||
export type putUpdateOrgMembersData = { | ||
orgId: string; | ||
members: { | ||
tmbId: string; | ||
role: `${OrgMemberRole}`; | ||
// role: `${OrgMemberRole}`; | ||
}[]; | ||
}; | ||
|
||
type putChnageOrgOwnerData = { | ||
orgId: string; | ||
tmbId: string; | ||
toAdmin?: boolean; | ||
}; | ||
|
||
type putUpdateOrgData = { | ||
export type putUpdateOrgData = { | ||
orgId: string; | ||
name?: string; | ||
avatar?: string; | ||
description?: string; | ||
}; | ||
|
||
type putMoveOrgData = { | ||
export type putMoveOrgData = { | ||
orgId: string; | ||
parentId: string; | ||
}; | ||
|
||
type putMoveOrgMemberData = { | ||
export type putMoveOrgMemberData = { | ||
orgId: string; | ||
tmbId: string; | ||
newOrgId: string; | ||
}; | ||
|
||
// type putChnageOrgOwnerData = { | ||
// orgId: string; | ||
// tmbId: string; | ||
// toAdmin?: boolean; | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
export const OrgCollectionName = 'team_orgs'; | ||
export const OrgMemberCollectionName = 'team_org_members'; | ||
|
||
export enum OrgMemberRole { | ||
owner = 'owner', | ||
admin = 'admin', | ||
member = 'member' | ||
} | ||
|
||
export const RootOrgName = 'ROOT'; | ||
// export enum OrgMemberRole { | ||
// owner = 'owner', | ||
// admin = 'admin', | ||
// member = 'member' | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import type { TeamPermission } from 'support/permission/user/controller'; | ||
import { ResourcePermissionType } from '../type'; | ||
import type { OrgMemberRole } from './constant'; | ||
|
||
type OrgSchemaType = { | ||
_id: string; | ||
teamId: string; | ||
path: string; | ||
name: string; | ||
avatar: string | undefined; | ||
description: string | undefined; | ||
avatar?: string; | ||
description?: string; | ||
updateTime: Date; | ||
}; | ||
|
||
type OrgMemberSchemaType = { | ||
teamId: string; | ||
orgId: string; | ||
tmbId: string; | ||
role: `${OrgMemberRole}`; | ||
}; | ||
|
||
type OrgType = OrgSchemaType & { | ||
type OrgType = Omit<OrgSchemaType, 'avatar'> & { | ||
avatar: string; | ||
members: OrgMemberSchemaType[]; | ||
permission: TeamPermission | undefined; | ||
permission?: TeamPermission; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller'; | ||
import { AuthModeType, AuthResponseType } from '../type'; | ||
import { parseHeaderCert } from '../controller'; | ||
import { getTmbInfoByTmbId } from '../../user/team/controller'; | ||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team'; | ||
|
||
export const authOrgMember = async ({ | ||
orgIds, | ||
req, | ||
authToken = false, | ||
authRoot = false, | ||
authApiKey = false | ||
}: { | ||
orgIds: string | string[]; | ||
} & AuthModeType): Promise<AuthResponseType> => { | ||
const result = await parseHeaderCert({ req, authToken, authApiKey, authRoot }); | ||
const { teamId, tmbId, isRoot } = 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 (!Array.isArray(orgIds)) { | ||
orgIds = [orgIds]; | ||
} | ||
|
||
// const promises = orgIds.map((orgId) => getOrgMemberRole({ orgId, tmbId })); | ||
|
||
const tmb = await getTmbInfoByTmbId({ tmbId }); | ||
if (tmb.permission.hasManagePer) { | ||
return { | ||
...result, | ||
permission: tmb.permission | ||
}; | ||
} | ||
|
||
return Promise.reject(TeamErrEnum.unAuthTeam); | ||
|
||
// const targetRole = OrgMemberRole[role]; | ||
// for (const orgRole of orgRoles) { | ||
// if (!orgRole || checkOrgRole(orgRole, targetRole)) { | ||
// return Promise.reject(TeamErrEnum.unAuthTeam); | ||
// } | ||
// } | ||
|
||
// return { | ||
// ...result, | ||
// permission: tmb.permission | ||
// }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.