Add shared registration invite helper and use it for admin-created users

This commit is contained in:
NeilClack
2026-09-10 14:08:51 -05:00
parent ae8d661364
commit 84c905c9ff
3 changed files with 28 additions and 23 deletions
+18
View File
@@ -0,0 +1,18 @@
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'
}
});
}