feat: implement auth session check and redirect on login page (#39)
This commit is contained in:
@@ -1,15 +1,14 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
// import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Auth } from "~/components/AuthForm";
|
import { Auth } from "~/components/AuthForm";
|
||||||
import { PageHead } from "~/components/PageHead";
|
import { PageHead } from "~/components/PageHead";
|
||||||
import PatternedBackground from "~/components/PatternedBackground";
|
import PatternedBackground from "~/components/PatternedBackground";
|
||||||
|
import { authClient } from "@kan/auth/client";
|
||||||
// import { api } from "~/utils/api";
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
// const router = useRouter();
|
const router = useRouter();
|
||||||
const [isMagicLinkSent, setIsMagicLinkSent] = useState<boolean>(false);
|
const [isMagicLinkSent, setIsMagicLinkSent] = useState<boolean>(false);
|
||||||
const [magicLinkRecipient, setMagicLinkRecipient] = useState<string>("");
|
const [magicLinkRecipient, setMagicLinkRecipient] = useState<string>("");
|
||||||
|
|
||||||
@@ -18,15 +17,9 @@ export default function LoginPage() {
|
|||||||
setMagicLinkRecipient(recipient);
|
setMagicLinkRecipient(recipient);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const authCookieExists = document.cookie
|
const { data } = authClient.useSession();
|
||||||
// .split("; ")
|
|
||||||
// .some((cookie) => cookie.includes("auth-token"));
|
|
||||||
|
|
||||||
// const { data } = api.user.getUser.useQuery(undefined, {
|
if (data?.user.id) router.push("/boards");
|
||||||
// enabled: authCookieExists ? true : false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (data?.id) router.push("/boards");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user