tutorbookapp/tutorbook

View on GitHub
lib/api/verify/is-org-admin.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { APIError } from 'lib/model/error';
import { Org } from 'lib/model/org';

export default function verifyIsOrgAdmin(org: Org, uid: string): void {
  if (!org.members.includes(uid)) {
    const msg = `You are not a ${org.name} admin. To fix, make sure to select yourself as a "Parent" above and try again.`;
    throw new APIError(msg, 400);
  }
}