Email a set-password link when an admin creates a user
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { sendMail } from './resend';
|
||||
|
||||
/**
|
||||
* Send the "finish your registration" email to a user created by an admin.
|
||||
*
|
||||
* The link points at Better Auth's reset-password callback, which redirects to
|
||||
* `/reset-password?invite=1&token=...`. There the user sets a password, then
|
||||
* logs in and is sent to `/profile/setup` to complete their profile.
|
||||
*
|
||||
* Uses a Resend-hosted template (`registration-email` by default, or
|
||||
* `RESEND_REGISTRATION_TEMPLATE_ID`) with variables:
|
||||
* - `target_email_address`
|
||||
* - `registration_link`
|
||||
*/
|
||||
export async function sendRegistrationEmail(options: { email: string; url: string }) {
|
||||
await sendMail({
|
||||
to: options.email,
|
||||
subject: 'Welcome to Radiant Wave — set your password',
|
||||
templateId: env.RESEND_REGISTRATION_TEMPLATE_ID || 'registration-email',
|
||||
data: {
|
||||
target_email_address: options.email,
|
||||
registration_link: options.url
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user