This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use server'
|
||||
|
||||
import { createAdminClient } from '@/lib/supabase/admin'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { sendMail } from '@/utils/mail';
|
||||
|
||||
export async function getUsers() {
|
||||
const admin = createAdminClient()
|
||||
@@ -79,6 +80,23 @@ export async function updateUserStatus(id: string, ban: boolean) {
|
||||
}
|
||||
|
||||
export async function resetPassword(email: string) {
|
||||
const admin = createAdminClient();
|
||||
// Generate password recovery link
|
||||
const { data, error } = await admin.auth.admin.generateLink({
|
||||
type: 'recovery',
|
||||
email,
|
||||
});
|
||||
if (error) throw error;
|
||||
const resetLink = data?.action_link || data?.link || '';
|
||||
if (!resetLink) throw new Error('Reset link not generated');
|
||||
// Send email via configured SMTP
|
||||
await sendMail({
|
||||
to: email,
|
||||
subject: 'Passwort zurücksetzen',
|
||||
text: `Klicken Sie auf den folgenden Link, um Ihr Passwort zurückzusetzen: ${resetLink}`,
|
||||
html: `<p>Klicken Sie <a href="${resetLink}">hier</a>, um Ihr Passwort zurückzusetzen.</p>`,
|
||||
});
|
||||
}
|
||||
const admin = createAdminClient()
|
||||
// Generate a reset link or send email
|
||||
const { error } = await admin.auth.admin.generateLink({
|
||||
|
||||
Reference in New Issue
Block a user