diff --git a/backend/spec.json b/backend/spec.json index adb8af411..e5ecb5df0 100644 --- a/backend/spec.json +++ b/backend/spec.json @@ -4962,7 +4962,8 @@ }, "security": [ { - "apiKeyAuth": [] + "apiKeyAuth": [], + "bearerAuth": [] } ] } diff --git a/backend/src/controllers/v2/organizationsController.ts b/backend/src/controllers/v2/organizationsController.ts index f939f9072..c6c49e23d 100644 --- a/backend/src/controllers/v2/organizationsController.ts +++ b/backend/src/controllers/v2/organizationsController.ts @@ -1,9 +1,13 @@ import { Request, Response } from "express"; import { Types } from "mongoose"; import { - IdentityMembershipOrg, - Membership, + IWorkspace, + Identity, + IdentityMembership, + IdentityMembershipOrg, + Membership, MembershipOrg, + User, Workspace } from "../../models"; import { Role } from "../../ee/models"; @@ -298,7 +302,8 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) => #swagger.description = 'Return projects in organization that user is part of' #swagger.security = [{ - "apiKeyAuth": [] + "apiKeyAuth": [], + "bearerAuth": [] }] #swagger.parameters['organizationId'] = { @@ -326,6 +331,7 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) => } } */ + const { params: { organizationId } } = await validateRequest(reqValidator.GetOrgWorkspacesv2, req); @@ -351,13 +357,27 @@ export const getOrganizationWorkspaces = async (req: Request, res: Response) => ).map((w) => w._id.toString()) ); - const workspaces = ( - await Membership.find({ - user: req.user._id - }).populate("workspace") - ) - .filter((m) => workspacesSet.has(m.workspace._id.toString())) - .map((m) => m.workspace); + let workspaces: IWorkspace[] = []; + + if (req.authData.authPayload instanceof Identity) { + workspaces = ( + await IdentityMembership.find({ + identity: req.authData.authPayload._id + }).populate<{ workspace: IWorkspace }>("workspace") + ) + .filter((m) => workspacesSet.has(m.workspace._id.toString())) + .map((m) => m.workspace); + } + + if (req.authData.authPayload instanceof User) { + workspaces = ( + await Membership.find({ + user: req.authData.authPayload._id + }).populate<{ workspace: IWorkspace }>("workspace") + ) + .filter((m) => workspacesSet.has(m.workspace._id.toString())) + .map((m) => m.workspace); + } return res.status(200).send({ workspaces diff --git a/docs/api-reference/endpoints/organizations/workspaces.mdx b/docs/api-reference/endpoints/organizations/workspaces.mdx index 34671fe73..2e2728e0c 100644 --- a/docs/api-reference/endpoints/organizations/workspaces.mdx +++ b/docs/api-reference/endpoints/organizations/workspaces.mdx @@ -1,10 +1,4 @@ --- title: "Get Projects" openapi: "GET /api/v2/organizations/{organizationId}/workspaces" ---- - - - This endpoint will be deprecated in the near future in Q1/Q2 2024. - - We recommend switching to using [identities](/documentation/platform/identities/overview). - \ No newline at end of file +--- \ No newline at end of file diff --git a/docs/spec.yaml b/docs/spec.yaml index a0a2dc13f..c3d050395 100644 --- a/docs/spec.yaml +++ b/docs/spec.yaml @@ -3133,6 +3133,7 @@ paths: description: Projects of organization security: - apiKeyAuth: [] + bearerAuth: [] /api/v2/organizations/: post: description: '' diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx index 7b8c55bf3..2807103c3 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx @@ -72,9 +72,9 @@ export const IdentitySection = withPermission(

- + Documentation - +
Name + ID Role Auth Method @@ -120,6 +121,7 @@ export const IdentityTable = ({ return ( {name} + {_id}