From 0094f3151b429305b890d186d8c5a1837d15072f Mon Sep 17 00:00:00 2001 From: Jade Allen Cook Date: Sun, 26 Nov 2023 22:55:24 -0800 Subject: [PATCH] feat: created a util to see if auth user is a mod --- src/utils/is-user-moderator.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/utils/is-user-moderator.ts diff --git a/src/utils/is-user-moderator.ts b/src/utils/is-user-moderator.ts new file mode 100644 index 0000000..925701d --- /dev/null +++ b/src/utils/is-user-moderator.ts @@ -0,0 +1,16 @@ +import OrganizationInterface from '@interfaces/organization'; + +const isUserModerator = ( + uid: string, + myOrganizations: string[], + organizations: { [key: string]: OrganizationInterface } +) => { + for (const organization of myOrganizations) { + if (organizations?.[organization]?.moderators.includes(uid)) { + return true; + } + } + return false; +}; + +export default isUserModerator;