fix(auth): register magic_link event type + use admin productId for enterprise IdP
- Register 'auth.magic_link_requested' in @bytelyst/events PlatformEventSchemas - Remove any-cast from magic-link/routes.ts — now properly typed - Enterprise IdP creation uses admin's JWT productId instead of hardcoded 'smartauth' - All 53 auth tests passing
This commit is contained in:
parent
b8f22be677
commit
2b3130821c
@ -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({
|
||||
|
||||
@ -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()),
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user