feat: session deletion, improved tasting deletion visibility, and PWA login loop fix

This commit is contained in:
2025-12-18 21:02:44 +01:00
parent a4a9d79c4c
commit a64e8f17a1
8 changed files with 174 additions and 32 deletions

View File

@@ -0,0 +1,35 @@
'use server';
import { createServerActionClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';
import { revalidatePath } from 'next/cache';
export async function deleteSession(sessionId: string) {
const supabase = createServerActionClient({ cookies });
try {
const { data: { session } } = await supabase.auth.getSession();
if (!session) {
throw new Error('Nicht autorisiert.');
}
const { error: deleteError } = await supabase
.from('tasting_sessions')
.delete()
.eq('id', sessionId)
.eq('user_id', session.user.id);
if (deleteError) throw deleteError;
revalidatePath('/');
revalidatePath(`/sessions/${sessionId}`);
return { success: true };
} catch (error) {
console.error('Delete Session Error:', error);
return {
success: false,
error: error instanceof Error ? error.message : 'Fehler beim Löschen der Session.',
};
}
}