fix: license key not showing in email when created via admin page
Problem: The admin createKey action had two issues preventing the license key from appearing in the delivery email: 1. Wrong variable name: passed 'licenseKey' (camelCase) but the Resend template expects 'license_key' (snake_case). 2. Wrong template: used the default RESEND_TEMPLATE_ID (a generic template) instead of the 'license-key-delivery' template that the automation endpoint uses for license key emails. Solution: - Changed template variable from 'licenseKey' to 'license_key' - Added explicit templateId: 'license-key-delivery' to match the automation endpoint (api/v1/automations/create/account) - Updated email subject to 'Your Rhemawave License Key' for consistency Tests: Added page.server.spec.ts for the admin license-keys createKey action covering: unauthenticated rejection, missing email/level validation, user-not-found error, successful key creation with correct template ID and license_key variable, fallback to user.name when profile is missing, and graceful handling when email sending fails.
This commit is contained in:
@@ -60,10 +60,11 @@ export const actions = {
|
||||
const profile = await prisma.profile.findUnique({ where: { userId: user.id } });
|
||||
await sendMail({
|
||||
to: email,
|
||||
subject: 'Your License Key',
|
||||
subject: 'Your Rhemawave License Key',
|
||||
templateId: 'license-key-delivery',
|
||||
data: {
|
||||
firstName: profile?.firstName ?? user.name ?? 'Valued Customer',
|
||||
licenseKey: key
|
||||
license_key: key
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user