Enforce action permissions across admin pages

Gate administration actions by role permissions, centralize cached session access for data fetching, and return forbidden responses for unauthorized pages. Also lazy-load user exports and adjust search field sizing.
This commit is contained in:
Ichsan Kurniawan
2026-11-09 15:02:29 +07:00
parent 8478b1f28f
commit 1b37ff65f5
14 changed files with 171 additions and 219 deletions
+3 -4
View File
@@ -1,12 +1,11 @@
import { getServerSession } from "next-auth"
import { redirect } from "next/navigation"
import { ResponseData } from "@/types/types"
import { logger } from "./logger"
import { authOptions } from "./auth"
import { getCacheServerSession } from "./get-access-data"
export default async function fetchData(url: string = '/', cache: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" = 'default', next?: NextFetchRequestConfig) {
const { BASE_URL_API } = process.env
const session = await getServerSession(authOptions)
const session = await getCacheServerSession()
const res = await fetch(BASE_URL_API + url, {
headers: {
@@ -34,7 +33,7 @@ export default async function fetchData(url: string = '/', cache: "default" | "f
export async function fetchDataWithPost(url: string = '/', payload: any = {}, cache: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" = 'default', next?: NextFetchRequestConfig) {
const { BASE_URL_API } = process.env
const session = await getServerSession(authOptions)
const session = await getCacheServerSession()
const res = await fetch(BASE_URL_API + url, {
headers: {