bananas-commerce-admin
Version:
What's this, an admin for apes?
9 lines (7 loc) • 346 B
text/typescript
import { User } from "../contexts/UserContext";
export function hasGroup(user: User | null | undefined, group: string | null | undefined): boolean {
if (user == null) return false;
if (group == null) return true;
if (user.is_superuser) return true;
return user.groups.map((group) => group.toLowerCase()).includes(group.toLowerCase());
}