Deploy staging to test server / deploy (push) Failing after 14m49s
This reverts commita55c69115d, reversing changes made to02c9c9f3d6.
19 lines
518 B
TypeScript
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" };
|
|
}
|