-
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.
* feat: add org schema * feat: org manage UI * feat: OrgInfoModal * feat: org tree view * feat: org management * fix: init root org * feat: org permission for app * feat: org support for dataset * fix: disable org role control * styles: opt type signatures * fix: remove unused permission * feat: delete org collaborator
- Loading branch information
Showing
46 changed files
with
1,933 additions
and
190 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
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export type postCreateOrgData = { | ||
name: string; | ||
parentId: string; | ||
description?: string; | ||
avatar?: string; | ||
}; | ||
|
||
export type putUpdateOrgMembersData = { | ||
orgId: string; | ||
members: { | ||
tmbId: string; | ||
// role: `${OrgMemberRole}`; | ||
}[]; | ||
}; | ||
|
||
export type putUpdateOrgData = { | ||
orgId: string; | ||
name?: string; | ||
avatar?: string; | ||
description?: string; | ||
}; | ||
|
||
export type putMoveOrgData = { | ||
orgId: string; | ||
parentId: string; | ||
}; | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const OrgCollectionName = 'team_orgs'; | ||
export const OrgMemberCollectionName = 'team_org_members'; | ||
|
||
// 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { TeamPermission } from 'support/permission/user/controller'; | ||
import { ResourcePermissionType } from '../type'; | ||
|
||
type OrgSchemaType = { | ||
_id: string; | ||
teamId: string; | ||
path: string; | ||
name: string; | ||
avatar?: string; | ||
description?: string; | ||
updateTime: Date; | ||
}; | ||
|
||
type OrgMemberSchemaType = { | ||
teamId: string; | ||
orgId: string; | ||
tmbId: string; | ||
}; | ||
|
||
type OrgType = Omit<OrgSchemaType, 'avatar'> & { | ||
avatar: string; | ||
members: OrgMemberSchemaType[]; | ||
}; |
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
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.