diff --git a/src/permissions/permissions.decorator.ts b/src/permissions/permissions.decorator.ts new file mode 100644 index 000000000..87e7d18de --- /dev/null +++ b/src/permissions/permissions.decorator.ts @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) + * + * SPDX-License-Identifier: AGPL-3.0-only + */ +import { CustomDecorator, SetMetadata } from '@nestjs/common'; + +import { Permission } from './permissions.enum'; + +/** + * This decorator gathers the {@link Permission Permission} a user must hold for the {@link PermissionsGuard} + * @param permissions - an array of permissions. In practice this should always contain exactly one {@link Permission} + * @constructor + */ +// eslint-disable-next-line func-style,@typescript-eslint/naming-convention +export const Permissions = (...permissions: Permission[]): CustomDecorator => + SetMetadata('permissions', permissions);