mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 00:27:35 +00:00
Multi-user organization invites structure
This commit is contained in:
@@ -16,23 +16,35 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
schema: {
|
schema: {
|
||||||
body: z.object({
|
body: z.object({
|
||||||
inviteeEmail: z.string().trim().email(),
|
inviteeEmails: z.array(z.string().trim().email()),
|
||||||
organizationId: z.string().trim()
|
organizationId: z.string().trim(),
|
||||||
|
projectIds: z.array(z.string().trim()).optional(),
|
||||||
|
organizationRoleSlug: z.string().trim().optional()
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
completeInviteLink: z.string().optional()
|
completeInviteLinks: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
email: z.string(),
|
||||||
|
link: z.string()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.optional()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT]),
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
if (req.auth.actor !== ActorType.USER) return;
|
if (req.auth.actor !== ActorType.USER) return;
|
||||||
const completeInviteLink = await server.services.org.inviteUserToOrganization({
|
|
||||||
|
const completeInviteLinks = await server.services.org.inviteUserToOrganization({
|
||||||
orgId: req.body.organizationId,
|
orgId: req.body.organizationId,
|
||||||
userId: req.permission.id,
|
userId: req.permission.id,
|
||||||
inviteeEmail: req.body.inviteeEmail,
|
inviteeEmails: req.body.inviteeEmails,
|
||||||
|
projectIds: req.body.projectIds,
|
||||||
|
organizationRoleSlug: req.body.organizationRoleSlug,
|
||||||
actorAuthMethod: req.permission.authMethod,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
actorOrgId: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
@@ -41,14 +53,15 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
event: PostHogEventTypes.UserOrgInvitation,
|
event: PostHogEventTypes.UserOrgInvitation,
|
||||||
distinctId: getTelemetryDistinctId(req),
|
distinctId: getTelemetryDistinctId(req),
|
||||||
properties: {
|
properties: {
|
||||||
inviteeEmail: req.body.inviteeEmail,
|
inviteeEmails: req.body.inviteeEmails,
|
||||||
|
organizationRoleSlug: req.body.organizationRoleSlug,
|
||||||
...req.auditLogInfo
|
...req.auditLogInfo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
completeInviteLink,
|
completeInviteLinks,
|
||||||
message: `Send an invite link to ${req.body.inviteeEmail}`
|
message: `Send an invite link to ${req.body.inviteeEmails.join(", ")}`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user