fix: sync verification state with auth guards

This commit is contained in:
zetaloop
2026-02-21 15:53:46 +08:00
parent 6469811382
commit 6ed8620ca6
5 changed files with 70 additions and 7 deletions
+19 -1
View File
@@ -1,8 +1,16 @@
"use client"
import Link from "next/link"
import { AuthGuard } from "@/components/auth-guard"
import { DashboardSidebar } from "@/components/dashboard-sidebar"
import { Header } from "@/components/header"
import { Button } from "@/components/ui/button"
import { useAuthStore } from "@/store/auth"
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
const isAuthenticated = useAuthStore((state) => state.isAuthenticated)
const currentRole = useAuthStore((state) => state.currentRole)
return (
<div className="flex min-h-screen flex-col">
<Header />
@@ -11,7 +19,17 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
<DashboardSidebar />
</div>
<main className="flex-1 p-6">
<AuthGuard>{children}</AuthGuard>
<AuthGuard>
{isAuthenticated && currentRole === "consumer" ? (
<div className="flex min-h-[50vh] items-center justify-center">
<Button asChild>
<Link href="/"></Link>
</Button>
</div>
) : (
children
)}
</AuthGuard>
</main>
</div>
</div>