all repos — caroster @ fbc9e225b5270c61549fce0c2fd4c1c1faa05e48

[Octree] Group carpool to your event https://caroster.io

backend/src/api/vehicle/policies/check-creation.ts (view raw)

 1import { errors } from "@strapi/utils";
 2
 3export default async (policyContext, config, { strapi }) => {
 4  const user = policyContext.state.user;
 5  if (!user)
 6    throw new errors.ForbiddenError(
 7      "Only authenticated user can create vehicle."
 8    );
 9
10  if (policyContext.args?.data?.user !== user.id)
11    throw new errors.UnauthorizedError(
12      "Can only create vehicle for authenticated user."
13    );
14};