mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 08:26:00 +00:00
Removed unused invite-signup endpoint (finally)
This commit is contained in:
@@ -2,13 +2,11 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
IntegrationsSchema,
|
IntegrationsSchema,
|
||||||
ProjectKeysSchema,
|
|
||||||
ProjectMembershipsSchema,
|
ProjectMembershipsSchema,
|
||||||
ProjectsSchema,
|
ProjectsSchema,
|
||||||
UserEncryptionKeysSchema,
|
UserEncryptionKeysSchema,
|
||||||
UsersSchema
|
UsersSchema
|
||||||
} from "@app/db/schemas";
|
} from "@app/db/schemas";
|
||||||
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
|
||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const workspace = await server.services.project.getAProject({
|
const workspace = await server.services.project.getAProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
@@ -171,7 +169,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const workspace = await server.services.project.deleteProject({
|
const workspace = await server.services.project.deleteProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
@@ -216,6 +214,41 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.route({
|
||||||
|
url: "/:workspaceId",
|
||||||
|
method: "PATCH",
|
||||||
|
schema: {
|
||||||
|
params: z.object({
|
||||||
|
workspaceId: z.string().trim()
|
||||||
|
}),
|
||||||
|
body: z.object({
|
||||||
|
name: z.string().trim().optional(),
|
||||||
|
autoCapitalization: z.boolean().optional()
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: z.object({
|
||||||
|
workspace: ProjectsSchema
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
|
handler: async (req) => {
|
||||||
|
const workspace = await server.services.project.updateProject({
|
||||||
|
actorId: req.permission.id,
|
||||||
|
actor: req.permission.type,
|
||||||
|
actorOrgId: req.permission.orgId,
|
||||||
|
projectId: req.params.workspaceId,
|
||||||
|
update: {
|
||||||
|
name: req.body.name,
|
||||||
|
autoCapitalization: req.body.autoCapitalization
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
workspace
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
url: "/:workspaceId/auto-capitalization",
|
url: "/:workspaceId/auto-capitalization",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -249,50 +282,6 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.route({
|
|
||||||
url: "/:workspaceId/invite-signup",
|
|
||||||
method: "POST",
|
|
||||||
schema: {
|
|
||||||
params: z.object({
|
|
||||||
workspaceId: z.string().trim()
|
|
||||||
}),
|
|
||||||
body: z.object({
|
|
||||||
email: z.string().trim()
|
|
||||||
}),
|
|
||||||
response: {
|
|
||||||
200: z.object({
|
|
||||||
invitee: UsersSchema,
|
|
||||||
latestKey: ProjectKeysSchema.optional()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onRequest: verifyAuth([AuthMode.JWT]),
|
|
||||||
handler: async (req) => {
|
|
||||||
const { invitees, latestKey } = await server.services.projectMembership.inviteUserToProject({
|
|
||||||
actorId: req.permission.id,
|
|
||||||
actor: req.permission.type,
|
|
||||||
actorOrgId: req.permission.orgId,
|
|
||||||
projectId: req.params.workspaceId,
|
|
||||||
emails: [req.body.email]
|
|
||||||
});
|
|
||||||
|
|
||||||
const invitee = invitees[0];
|
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
|
||||||
...req.auditLogInfo,
|
|
||||||
projectId: req.params.workspaceId,
|
|
||||||
event: {
|
|
||||||
type: EventType.ADD_WORKSPACE_MEMBER,
|
|
||||||
metadata: {
|
|
||||||
userId: invitee.id,
|
|
||||||
email: invitee.email
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return { invitee, latestKey };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
url: "/:workspaceId/integrations",
|
url: "/:workspaceId/integrations",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
export {
|
export {
|
||||||
useAddIdentityToWorkspace,
|
useAddIdentityToWorkspace,
|
||||||
useAddUserToWorkspace,
|
|
||||||
useCreateWorkspace,
|
useCreateWorkspace,
|
||||||
useCreateWsEnvironment,
|
useCreateWsEnvironment,
|
||||||
useDeleteIdentityFromWorkspace,
|
useDeleteIdentityFromWorkspace,
|
||||||
|
|||||||
@@ -319,28 +319,6 @@ export const useGetWorkspaceUsers = (workspaceId: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useAddUserToWorkspace = () => {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: async ({ email, workspaceId }: { email: string; workspaceId: string }) => {
|
|
||||||
const {
|
|
||||||
data: { invitees, latestKey }
|
|
||||||
} = await apiRequest.post(`/api/v1/workspace/${workspaceId}/invite-signup`, {
|
|
||||||
emails: [email]
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
invitees,
|
|
||||||
latestKey
|
|
||||||
};
|
|
||||||
},
|
|
||||||
onSuccess: (_, dto) => {
|
|
||||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(dto.workspaceId));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useDeleteUserFromWorkspace = () => {
|
export const useDeleteUserFromWorkspace = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user