add: full auth functionality

add: zustand auth store
add: jwt auto refresh
This commit is contained in:
Mahyar Khanbolooki
2025-07-01 22:49:56 +03:30
parent ef63706116
commit 48c458f012
22 changed files with 340 additions and 53 deletions
+10 -4
View File
@@ -1,18 +1,24 @@
'use client';
import { useAuthStore } from "@/zustand/userStore";
import { useAuthStore } from "@/zustand/authStore";
import Image from "next/image";
import Link from "next/link";
export default function Home() {
const logout = useAuthStore((state) => state.logout);
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
return (
<div className="grid font-sans grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<div className="grid font-sans grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20">
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
<Link href={"/auth"}>Login</Link>
<Link href={"/"} onClick={logout}>Logout</Link>
{!isAuthenticated && <Link href={"/auth"}>Login</Link>}
{isAuthenticated &&
<div>
<Link href={"/profile"}>Profile</Link>
<br />
<Link href={""} onClick={logout}>Logout</Link>
</div>}
<Image
className="dark:invert"
src="/next.svg"