12 lines
308 B
TypeScript
12 lines
308 B
TypeScript
import { ForbiddenException } from '@nestjs/common';
|
|
|
|
export function assertOwner(
|
|
ownerId: string | null | undefined,
|
|
userId: string,
|
|
resourceName: string,
|
|
): void {
|
|
if (!ownerId || ownerId !== userId) {
|
|
throw new ForbiddenException(`${resourceName} does not belong to the current user`);
|
|
}
|
|
}
|