Files
Compass/backend/shared/src/helpers/auth.ts
2025-08-27 21:30:05 +02:00

12 lines
336 B
TypeScript

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