diff --git a/packages/events/src/types.ts b/packages/events/src/types.ts index cde80f65..c1bd856f 100644 --- a/packages/events/src/types.ts +++ b/packages/events/src/types.ts @@ -67,6 +67,13 @@ export const PlatformEventSchemas = { secondaryUserId: z.string(), productId: z.string(), }), + 'auth.magic_link_requested': z.object({ + userId: z.string(), + email: z.string(), + token: z.string(), + productId: z.string(), + expiresAt: z.string(), + }), // Subscription events 'subscription.created': z.object({ diff --git a/services/platform-service/src/modules/auth/enterprise/routes.ts b/services/platform-service/src/modules/auth/enterprise/routes.ts index 7e2db54c..961d27ed 100644 --- a/services/platform-service/src/modules/auth/enterprise/routes.ts +++ b/services/platform-service/src/modules/auth/enterprise/routes.ts @@ -53,10 +53,11 @@ export async function enterpriseRoutes(app: FastifyInstance) { } const now = new Date().toISOString(); + const adminProductId = payload.productId ?? 'smartauth'; const doc: EnterpriseIdpDoc = { id: `idp_${data.orgId}_${data.protocol}_${randomUUID().slice(0, 6)}`, orgId: data.orgId, - productId: 'smartauth', + productId: adminProductId, protocol: data.protocol, name: data.name, emailDomains: data.emailDomains.map(d => d.toLowerCase()), diff --git a/services/platform-service/src/modules/auth/magic-link/routes.ts b/services/platform-service/src/modules/auth/magic-link/routes.ts index 363863dc..355f0f73 100644 --- a/services/platform-service/src/modules/auth/magic-link/routes.ts +++ b/services/platform-service/src/modules/auth/magic-link/routes.ts @@ -49,8 +49,7 @@ export async function magicLinkRoutes(app: FastifyInstance) { await repo.create(doc); // Emit event for delivery module to send email - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (bus as any).emit('auth.magic_link_requested', { + await bus.emit('auth.magic_link_requested', { userId: user.id, email: user.email, token,