diff --git a/shop/lib/actions/users.ts b/shop/lib/actions/users.ts index 0273ddf..9623b22 100644 --- a/shop/lib/actions/users.ts +++ b/shop/lib/actions/users.ts @@ -85,10 +85,12 @@ export async function resetPassword(email: string) { }); if (error) throw error; const linkData = data as any; - let resetLink = linkData?.properties?.action_link || linkData?.action_link || linkData?.link || ''; - if (!resetLink) throw new Error('Reset link not generated'); - // Fix: replace localhost URLs with actual site URL - resetLink = resetLink.replace(/http:\/\/localhost:\d+/g, process.env.NEXT_PUBLIC_SITE_URL || 'https://staging.hephex.de'); + // Extract token_hash from the generated link properties + const tokenHash = linkData?.properties?.hashed_token; + if (!tokenHash) throw new Error('Recovery token not generated'); + // Build link pointing to our own /auth/confirm route + const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://staging.hephex.de'; + const resetLink = `${siteUrl}/auth/confirm?token_hash=${tokenHash}&type=recovery&next=/auth/update-password`; await sendMail({ to: email, subject: 'Passwort zurücksetzen',