UNPKG

bananas-commerce-admin

Version:

What's this, an admin for apes?

18 lines (15 loc) 546 B
import { User } from "../contexts/UserContext"; import { hasGroup } from "./has_group"; import { hasPermission } from "./has_permission"; export function hasAccess( user: User | null | undefined, permission: string | null | undefined, group: string | null | undefined, ): boolean { let access = false; if (user == null) access = false; if (permission == null && group == null) access = true; if (group != null) access = hasGroup(user, group); if (permission != null) access = hasPermission(user, permission); return access; }