Files
portal/src/lib/server/registration-invite.ts
T

19 lines
630 B
TypeScript

import { auth } from '$lib/auth';
/**
* Email an invited user a link to set their password and finish their profile.
*
* Reuses Better Auth's password-reset token flow; the `invite=1` marker makes
* the reset-password hook send the `registration-email` template instead of the
* usual "you requested a reset" email. The link lands on /reset-password, and
* after setting a password the user logs in and is sent to /profile/setup.
*/
export async function sendRegistrationInvite(email: string): Promise<void> {
await auth.api.requestPasswordReset({
body: {
email,
redirectTo: '/reset-password?invite=1'
}
});
}