mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 23:16:29 +00:00
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:
+3
-4
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user