first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
18
packages/auth/lib/helper.ts
Normal file
18
packages/auth/lib/helper.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import type { ActiveOrganization } from "../auth";
|
||||
|
||||
export function isOrganizationAdmin(
|
||||
organization?: ActiveOrganization | null,
|
||||
user?: {
|
||||
id: string;
|
||||
role?: string | null;
|
||||
} | null,
|
||||
) {
|
||||
const userOrganizationRole = organization?.members.find(
|
||||
(member) => member.userId === user?.id,
|
||||
)?.role;
|
||||
|
||||
return (
|
||||
["owner", "admin"].includes(userOrganizationRole ?? "") ||
|
||||
user?.role === "admin"
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue