Add shared registration invite helper and use it for admin-created users
This commit is contained in:
@@ -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'
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user