Files
Jyotisha/frontend/src/lib/admin/auth-policy.ts
T
linmeng f4e35974c6
Deploy staging to test server / deploy (push) Failing after 14m49s
Revert "merge: sync GitHub staging to Gitea"
This reverts commit a55c69115d, reversing
changes made to 02c9c9f3d6.
2026-07-30 14:38:17 +08:00

19 lines
518 B
TypeScript

import type { IdentityUser } from "@/modules/identity/contracts";
export type AdminRole = "admin";
export type AdminAccessResult =
| { allowed: true; role: AdminRole }
| { allowed: false; status: 401 | 403 };
export function authorizeAdminAccess(
user: IdentityUser | null,
access: "read" | "write",
): AdminAccessResult {
if (!user) return { allowed: false, status: 401 };
if (!user.role.includes("admin")) {
return { allowed: false, status: 403 };
}
return { allowed: true, role: "admin" };
}