From 055a778c98a5b39a2c1ac0b3c7c83d36e600574a Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Tue, 4 Apr 2023 16:00:48 +0200 Subject: [PATCH] fix(redirect when unauthenthicated): authenticated --- src/pages/userProfile.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/userProfile.tsx b/src/pages/userProfile.tsx index 57d0708..b7609fc 100644 --- a/src/pages/userProfile.tsx +++ b/src/pages/userProfile.tsx @@ -61,10 +61,6 @@ export default function UserProfile() { const { data: session, status } = useSession(); - // if (status === "unauthenticated") router.push("/login"); - - // if (status === "authenticated") { - const { isLoading, isError, @@ -85,10 +81,17 @@ export default function UserProfile() { }); if (isLoading) { + if (status === "unauthenticated") router.push("/login"); return ; } 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 Error: {error.message}; }