Add Better Auth admin authentication
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { isAuthenticated } from "@/lib/auth-server";
|
||||
import { DashboardSidebar } from "@/components/dashboard-sidebar";
|
||||
import { getCurrentMockSession } from "@/lib/mock-session";
|
||||
import { getDashboardRedirectPath } from "@/lib/route-guards";
|
||||
|
||||
export default async function DashboardLayout({
|
||||
@@ -9,16 +9,16 @@ export default async function DashboardLayout({
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const session = await getCurrentMockSession();
|
||||
const redirectPath = getDashboardRedirectPath(session);
|
||||
const hasSession = await isAuthenticated();
|
||||
const redirectPath = getDashboardRedirectPath(hasSession);
|
||||
|
||||
if (redirectPath || !session) {
|
||||
if (redirectPath) {
|
||||
redirect(redirectPath ?? "/");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-dvh bg-background md:flex">
|
||||
<DashboardSidebar session={session} />
|
||||
<DashboardSidebar />
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user