251208:1625 Frontend: to be complete admin panel, Backend: tobe recheck all task
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
admin
2025-12-08 16:25:56 +07:00
parent dcd126d704
commit 863a727756
64 changed files with 5956 additions and 1256 deletions

View File

@@ -1,7 +1,6 @@
import { AdminSidebar } from "@/components/admin/sidebar";
import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { auth } from "@/lib/auth";
export default async function AdminLayout({
@@ -9,16 +8,13 @@ export default async function AdminLayout({
}: {
children: React.ReactNode;
}) {
const session = await getServerSession(authOptions);
const session = await auth();
// Check if user has admin role
// This depends on your Session structure. Assuming user.roles exists (mapped in callback).
// If not, you might need to check DB or use Can component logic but server-side.
const isAdmin = session?.user?.roles?.some((r: any) => r.role_name === 'ADMIN');
// Temporary bypass for UI testing
const isAdmin = true; // session?.user?.role === 'ADMIN';
if (!session || !isAdmin) {
// If not admin, redirect to dashboard or login
redirect("/");
// redirect("/");
}
return (