diff --git a/shop/components/login-form.tsx b/shop/components/login-form.tsx index 0304324..b13560e 100644 --- a/shop/components/login-form.tsx +++ b/shop/components/login-form.tsx @@ -32,9 +32,12 @@ export function LoginForm({ setError(null); try { - await signIn(email, password); - // Update this route to redirect to an authenticated route. The user already has an active session. - router.push("/protected"); + const res = await signIn(email, password); + if (res.role === "admin") { + router.push("/admin/einstellungen"); + } else { + router.push("/my-customers"); + } } catch (error: unknown) { setError(error instanceof Error ? error.message : "An error occurred"); } finally { diff --git a/shop/components/update-password-form.tsx b/shop/components/update-password-form.tsx index 5b4f2e2..fdf023f 100644 --- a/shop/components/update-password-form.tsx +++ b/shop/components/update-password-form.tsx @@ -31,8 +31,7 @@ export function UpdatePasswordForm({ try { await updatePassword(password); - // Update this route to redirect to an authenticated route. The user already has an active session. - router.push("/protected"); + router.push("/"); } catch (error: unknown) { setError(error instanceof Error ? error.message : "An error occurred"); } finally { diff --git a/shop/lib/actions/auth.ts b/shop/lib/actions/auth.ts index cc7ae0b..410257d 100644 --- a/shop/lib/actions/auth.ts +++ b/shop/lib/actions/auth.ts @@ -28,9 +28,11 @@ export async function signIn(email: string, password: string) { // Andere aktive Sitzungen beenden await supabase.auth.signOut({ scope: 'others' }) + + return { success: true, role: userData.role } } - return { success: true } + return { success: true, role: 'partner' } } export async function signUp(email: string, password: string) { diff --git a/shop/lib/actions/orders.ts b/shop/lib/actions/orders.ts index 690565a..b6a82c6 100644 --- a/shop/lib/actions/orders.ts +++ b/shop/lib/actions/orders.ts @@ -185,7 +185,7 @@ export async function submitOrder(params: { console.error('PDF Generation Error:', pdfError) } - revalidatePath('/protected') + revalidatePath('/my-customers') revalidatePath('/my-orders') return order as Order }