fix home page not working with invalid session

This commit is contained in:
Matthias Nannt
2023-03-30 13:44:13 +02:00
parent e2d76a6ba3
commit b73939d9d0

View File

@@ -1,6 +1,7 @@
"use client";
import { fetcher } from "@formbricks/lib/fetcher";
import { signOut } from "next-auth/react";
import { redirect } from "next/navigation";
import { useEffect } from "react";
import useSWR from "swr";
@@ -11,8 +12,17 @@ export function HomeRedirect() {
useEffect(() => {
if (data && !error) {
return redirect(`/environments/${data.id}`);
} else if (error) {
console.error(error);
}
}, [data, error]);
return <div>{error && error.toString()}</div>;
if (error) {
setTimeout(() => {
signOut();
}, 3000);
return <div>There was an error with your current Session. You are getting redirected to the login.</div>;
}
return <div>Loading environment...</div>;
}