Files
Compass/backend/shared/src/helpers/auth.ts
2026-03-06 15:27:49 +01:00

9 lines
317 B
TypeScript

import {APIErrors} from 'common/api/utils'
import {isAdminId, isModId} from 'common/envs/constants'
export const throwErrorIfNotMod = async (userId: string) => {
if (!isAdminId(userId) && !isModId(userId)) {
throw APIErrors.forbidden(`User ${userId} must be an admin or trusted to perform this action.`)
}
}