fix(redirect when unauthenthicated): authenticated

This commit is contained in:
Laurian-Dufrechou
2023-04-04 16:00:48 +02:00
parent 4e81a903fe
commit 055a778c98
+7 -4
View File
@@ -61,10 +61,6 @@ export default function UserProfile() {
const { data: session, status } = useSession(); const { data: session, status } = useSession();
// if (status === "unauthenticated") router.push("/login");
// if (status === "authenticated") {
const { const {
isLoading, isLoading,
isError, isError,
@@ -85,10 +81,17 @@ export default function UserProfile() {
}); });
if (isLoading) { if (isLoading) {
if (status === "unauthenticated") router.push("/login");
return <LoadingPage />; return <LoadingPage />;
} }
if (isError) { if (isError) {
toast({
title: `Erreur lors de la récupération des données du profil`,
status: "error",
position: "top",
});
if (status === "unauthenticated") router.push("/");
return <span>Error: {error.message}</span>; return <span>Error: {error.message}</span>;
} }