mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
fix home page not working with invalid session
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user