From 0994fc8baf199be34ff8947b1a360f8c3bb1be6d Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 7 May 2024 22:58:02 +0100 Subject: [PATCH] fix: remove redirect when authenticated --- src/views/auth/login/index.tsx | 20 ++++++++++---------- src/views/auth/signup/index.tsx | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/views/auth/login/index.tsx b/src/views/auth/login/index.tsx index a4335399..d7968232 100644 --- a/src/views/auth/login/index.tsx +++ b/src/views/auth/login/index.tsx @@ -1,10 +1,10 @@ import { useState } from "react"; -import { useRouter } from "next/navigation"; +// import { useRouter } from "next/navigation"; import { Auth } from "~/components/AuthForm"; -import { api } from "~/utils/api"; +// import { api } from "~/utils/api"; export default function LoginPage() { - const router = useRouter(); + // const router = useRouter(); const [isMagicLinkSent, setIsMagicLinkSent] = useState(false); const [magicLinkRecipient, setMagicLinkRecipient] = useState(""); @@ -13,15 +13,15 @@ export default function LoginPage() { setMagicLinkRecipient(recipient); }; - const authCookieExists = document.cookie - .split("; ") - .some((cookie) => cookie.includes("auth-token")); + // const authCookieExists = document.cookie + // .split("; ") + // .some((cookie) => cookie.includes("auth-token")); - if (authCookieExists) { - const { error } = api.auth.getUser.useQuery(); + // const { data } = api.auth.getUser.useQuery(undefined, { + // enabled: authCookieExists ? true : false, + // }); - if (!error) router.push("/boards"); - } + // if (data?.id) router.push("/boards"); return (
diff --git a/src/views/auth/signup/index.tsx b/src/views/auth/signup/index.tsx index 5ad80de0..cba9e8be 100644 --- a/src/views/auth/signup/index.tsx +++ b/src/views/auth/signup/index.tsx @@ -1,10 +1,10 @@ import { useState } from "react"; -import { useRouter } from "next/navigation"; +// import { useRouter } from "next/navigation"; import { Auth } from "~/components/AuthForm"; -import { api } from "~/utils/api"; +// import { api } from "~/utils/api"; export default function SignupPage() { - const router = useRouter(); + // const router = useRouter(); const [isMagicLinkSent, setIsMagicLinkSent] = useState(false); const [magicLinkRecipient, setMagicLinkRecipient] = useState(""); @@ -13,15 +13,15 @@ export default function SignupPage() { setMagicLinkRecipient(recipient); }; - const authCookieExists = document.cookie - .split("; ") - .some((cookie) => cookie.includes("auth-token")); + // const authCookieExists = document.cookie + // .split("; ") + // .some((cookie) => cookie.includes("auth-token")); - if (authCookieExists) { - const { error } = api.auth.getUser.useQuery(); + // const { data } = api.auth.getUser.useQuery(undefined, { + // enabled: authCookieExists ? true : false, + // }); - if (!error) router.push("/boards"); - } + // if (data?.id) router.push("/boards"); return (